Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs Grunt服务器连接代理在发布后获得504_Gruntjs - Fatal编程技术网

Gruntjs Grunt服务器连接代理在发布后获得504

Gruntjs Grunt服务器连接代理在发布后获得504,gruntjs,Gruntjs,使用代理的Grunt服务器有点问题 我一切都很好,但是,当我提交一个post请求时,我的代理成功了200次 随后每次使用该代理,我都会得到504网关超时 例如,如果我向未成年人学生代理发帖,它会通过罚款。 每次之后,当我尝试用代理做其他事情时,我都会得到一个504 我可以通过get使用其他代理,我可以获得条款和课程 好像有什么东西挂着,抛出了某种错误,但我看不出来 如有任何见解,将不胜感激 下面是带有代理的connect服务器的一个片段 //定义所有任务的配置 grunt.initConfig

使用代理的Grunt服务器有点问题

我一切都很好,但是,当我提交一个post请求时,我的代理成功了200次

随后每次使用该代理,我都会得到504网关超时

例如,如果我向未成年人学生代理发帖,它会通过罚款。 每次之后,当我尝试用代理做其他事情时,我都会得到一个504

我可以通过get使用其他代理,我可以获得条款和课程

好像有什么东西挂着,抛出了某种错误,但我看不出来

如有任何见解,将不胜感激

下面是带有代理的connect服务器的一个片段

//定义所有任务的配置
grunt.initConfig({
连接:{
规则:[
{从:'^/poc proxy/(.*)$'到:'/authorizations/$1'},
{从:'^/service/api/terms/(.*)$'到:'/terms/$1'},
{从:'^/service/api/courses/(.*)$'到:'/courses/$1'},
{从:'^/service/api/studentsubscribes/(.*)$'到:'/studentsubscribes/$1'}
],
服务器:{
选项:{
港口:9000,
基地:'开发',
主机名:“localhost”,
中间件:功能(连接、恢复、选项、中间件){
返回[
重写规则,
serveStatic('./dev'),
require('grunt-middleware-proxy/lib/Utils')。getProxyMiddleware()
]
}
},
代理:[{
上下文:“/authorizations”,//必需!必须以“/”开头,不应以“/”结尾
主机:“authorizations.com”,//必需!不应包含“http://”或“https://”
来源:对,
https:true,//可选,默认为false
标题:{//可选。
“访问控制允许来源”:“*”
}
},
{
上下文:'/terms',//必需!必须以“/”开头,不应以“/”结尾
主机:“terms.com”,//必需!不应包含“http://”或“https://”
来源:对,
https:true,//可选,默认为false
标题:{//可选。
“访问控制允许来源”:“*”
}
},
{
上下文:'/courses',//必需!必须以'/'开头,不应以'/'结尾
主机:“courses.com”,//必需!不应包含“http://”或“https://”
来源:对,
https:true,//可选,默认为false
标题:{//可选。
“访问控制允许来源”:“*”
}
},
{
上下文:“/studentsubjectors”,//必需!必须以“/”开头,不应以“/”结尾
主机:“subjectors.com”,//必需!不应包含“http://”或“https://”
https:是的,
来源:对,
标题:{//可选。
“访问控制允许来源”:“*”
}
}
]
}

},
更改了服务器选项

    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
                       ]
            }
        },
已更改任务运行

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'
  ]);
});

更改了服务器选项

    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
                       ]
            }
        },
已更改任务运行

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'
  ]);
});

我们切换到使用grunt connect proxy,但最新版本仍然存在问题。我们强制grunt connect proxy始终在package.json中使用0.1.10,这似乎已经为我们解决了问题。我们切换到使用grunt connect proxy,但最新版本仍然存在问题。我们强制grunt connect proxy始终在package.json中使用0.1.10json,这似乎为我们解决了这个问题。