2
所以我在GAE上部署了一個nodeJS腳本,並且每當我點擊一個POST端點時,我得到一個502錯誤網關錯誤。端點是一個簡單的服務,它使用phantomJS抓取頁面的屏幕截圖,並返回一個JSON,其中包含圖像的base64表示形式。谷歌應用程序引擎:只有在POST請求502壞網關
做一個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;
備註: 該代碼適用於我的本地環境。
該代碼是否在你的本地開發環境中工作? –
@VikramTiwari是的,它對我的本地環境非常有效。 –
@HarrisRobinKalash你能解決它嗎?我面臨着同樣的問題.. –