2
GAEにnodeJSスクリプトをデプロイしました。その結果、POSTエンドポイントに到達するたびに502 Bad Gatewayエラーが発生しました。エンドポイントは、phantomJSを使用してページのスクリーンショットを取得し、そこにイメージのbase64表現を含むJSONを返す単純なサービスです。Googleアプリケーションエンジン:502 POSTリクエストのゲートウェイが正しくありません
このエンドポイントへのGETを行うと、正常に動作し、しかし、すぐに私は私が手にPOSTリクエストを試すよう、健全な200応答を返します。
: 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はい、私のローカル環境で完全に動作します。 –
@ハリスロビンカラシあなたはそれを解決できましたか?私は同じ問題に直面しています。 –