The nodejs application should then be working fine based on the information 
you've provided.

You are however correct that the *app.yaml* needs to be changed.  The *url* 
<https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml#security>
 
of your main handler is incorrect to pass requests along to your nodejs 
application.  Please note that the *url* property in the YAML is a POSIX 
extended regular expression 
<https://en.wikipedia.org/wiki/Regular_expression>.  From the app.yaml you 
described in your first message, I presume you would like to route all 
requests to your nodejs application.  To accomplish this, the recommended 
expression is */.**.  So the secure handlers would look like this:
handlers:
- url: /.*
  script: app.js
  secure: always

This will route all requests to the your nodejs application and redirect to 
*https* to respect *secure: always*.  Let me know if you still encounter 
this issue.  

On Monday, May 30, 2016 at 9:42:45 PM UTC-4, Harris Robin Kalash wrote:
>
> 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/0a0b8ca1-0eba-446c-8496-e8eee47e3b54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to