So I deployed a nodeJS script on GAE and whenever I hit a POST endpoint I
get a 502 Bad Gateway error. The endpoint is a simple service that grabs a
screenshot of a page using phantomJS and returns a JSON that contains the
base64 representation of the image in it.
Doing a GET to this endpoint works fine and returns a healthy 200 response,
however as soon as I try a POST request I get: **502 Bad Gateway**
Here is my **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
My **app.js** script:
'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;
Notes:
**The code works on my local environment.**
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/e142a765-9737-44ab-a530-b715bf582648%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.