Google应用引擎:仅在POST请求中使用502 Bad Gateway

所以我在GAE上部署了一个nodeJS脚本,每当我遇到一个POST端点时,我得到一个502错误的网关错误。 端点是一个简单的服务,使用phantomJS获取页面的屏幕截图,并返回一个JSON,其中包含图像的base64表示。

做一个GET到这个端点工作正常,并返回一个健康的200响应,但是一旦我尝试一个POST请求,我得到: 502坏的网关

这是我的app.yaml

service: pdf-service # [START runtime] runtime: nodejs vm: true # [END runtime] threadsafe: yes # Temporary setting to keep gcloud from uploading node_modules skip_files: - ^node_modules$ handlers: - url: (.*)/ script: app.js secure: always 

我的app.js脚本:

 'use strict'; var express = require('express'); var app = express(); var cors = require('cors'); var bodyParser = require('body-parser') var phantom = require('./phantom'); app.use(cors()); // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) var tmpURL = 'https://www.google.com'; // [START hello_world] // Say hello! app.post('/', function(req, res) { console.log('requrl', req.body); phantom.takeScreenShot(tmpURL, res); }); app.get('/', function(req, res) { res.status(200).send({'greetings': 'Hello World'}); }); // [END hello_world] if (module === require.main) { // [START server] // Start the server var server = app.listen(process.env.PORT || 8080, function() { var host = server.address().address; var port = server.address().port; console.log('App listening at http://%s:%s', host, port); }); // [END server] } module.exports = app; 

注意: 代码适用于我的本地环境。

看看这里 :

阅读日志帮助我了解是什么导致了我的端点上的问题。 即

“gcloud应用程序日志读取”