2016-09-17 1 views
1

Haben ein bisschen ein Problem mit Grunt Server mit Proxies.Grunt Server verbinden Proxy bekommen 504 nach einem POST

Ich habe alles funktioniert gut, jedoch, wenn ich eine Post-Anfrage senden, bekomme ich einen 200-Erfolg von meinem Proxy.

Dann bekomme ich mit jeder folgenden Verwendung dieses Proxy ein 504 Gateway Timeout.

Zum Beispiel, wenn ich auf Student-Minderjährigen-Proxy posten geht es gut durch. Jedes Mal danach bekomme ich eine 504, wenn ich versuche, etwas anderes mit diesem Proxy zu tun.

Ich kann die anderen Proxies mit einem bekommen, ich kann Begriffe und Kurse bekommen.

Scheint wie etwas hängt entweder, einen Fehler irgendeiner Art werfend, aber ich kann es nicht sehen.

Jeder Einblick wäre willkommen.

Hier ist ein Ausschnitt aus dem Connect-Server mit dem Proxy-Material

// Define the configuration for all the tasks 
 
    grunt.initConfig({ 
 
    connect: { 
 
      rules: [ 
 
         {from: '^/poc-proxy/(.*)$', to: '/authorizations/$1'}, 
 
         {from: '^/service/apis/terms/(.*)$', to: '/terms/$1'}, 
 
         {from: '^/service/apis/courses/(.*)$', to: '/courses/$1'}, 
 
         {from: '^/service/apis/studentMinors/(.*)$', to: '/studentMinors/$1'} 
 
        ], 
 
     server: { 
 
      options: { 
 
       port: 9000, 
 
       base: 'dev', 
 
       hostname: 'localhost', 
 
       middleware: function (connect, res,options, middlewares) { 
 
        return [ 
 
        rewriteRules, 
 
        serveStatic('./dev'), 
 
        require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware() 
 
        ] 
 
       } 
 
      }, 
 
      proxies: [{ 
 
        context: '/authorizations', //REQUIRED! Must start with a '/' should not end with a '/' 
 
        host: 'authorizations.com', //REQUIRED! Should not contain 'http://' or 'https://' 
 
        changeOrigin: true, 
 
        https: true,//Optional, defaults to false 
 
        headers: {//Optional. 
 
         'Access-Control-Allow-Origin': '*' 
 
        } 
 
        }, 
 
        { 
 
        context: '/terms', //REQUIRED! Must start with a '/' should not end with a '/' 
 
        host: 'terms.com', //REQUIRED! Should not contain 'http://' or 'https://' 
 
        changeOrigin: true, 
 
        https: true,//Optional, defaults to false 
 
        headers: {//Optional. 
 
         'Access-Control-Allow-Origin': '*' 
 
        } 
 
       }, 
 
       { 
 
        context: '/courses', //REQUIRED! Must start with a '/' should not end with a '/' 
 
        host: 'courses.com', //REQUIRED! Should not contain 'http://' or 'https://' 
 
        changeOrigin: true, 
 
        https: true,//Optional, defaults to false 
 
        headers: {//Optional. 
 
         'Access-Control-Allow-Origin': '*' 
 
        } 
 
       }, 
 
       { 
 
        context: '/studentMinors', //REQUIRED! Must start with a '/' should not end with a '/' 
 
        host: 'minors.com', //REQUIRED! Should not contain 'http://' or 'https://' 
 
        https: true, 
 
        changeOrigin: true, 
 
        headers: {//Optional. 
 
         'Access-Control-Allow-Origin': '*' 
 
        } 
 
        } 
 
       ] 
 
     } 
 
    },

+0

Wir schalteten Grunzen-Connect-Proxy zu verwenden, aber wir hatten immer noch ein Problem mit der neuesten Version. –

+0

Wir zwangen grunt-connect-proxy immer 0.1.10 in package.json zu verwenden und das scheint es für uns behoben zu haben. –

Antwort

0

die Serveroptionen geändert.

server: { 
     options: { 
      port: 9000, 
      base: 'dev', 
      hostname: 'localhost', 
      middleware: function (connect, res,options, middlewares) { 
       return [ 
          rewriteRules, 
          serveStatic('./dev'), 
          //require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware() 
          require('grunt-connect-proxy/lib/utils').proxyRequest 
         ] 
      } 
     }, 

den Lauf Aufgabe geändert

grunt.registerTask('serve', 'start the server and preview your app', function (target) { 

    if (target === 'dist') { 
    return grunt.task.run(['build', 'browserSync:dist']); 
    } 

    grunt.task.run([ 
    'configureRewriteRules', 
    //'setupProxies:server', 
    'configureProxies:server', 
    'connect:server', 
    'clean:server', 
    'wiredep', 
    'concurrent:server', 
    'postcss:dev', 
    'copy:dev', 
    //'browserSync:livereload', //Browsersync a proxy servers conflict with CORS 
    'watch' 
    ]); 
}); 
Verwandte Themen