0

I have the following context path handlers in my app.yaml:

runtime: nodejs
env: flex

resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 20

handlers:
- url: /api
  secure: always
  script: app.js

- url: /
  secure: always
  static_dir: public

Static works OK. There are two problems i have:

secure: always

pragma does not work as expected. There's no redirect from http to https.

Second, i have /test endpoint in my NodeJS app. However /api/test is 404, but /test works, ignoring /api.

What am I doing wrong?

Generated runtime config:

runtime: nodejs
api_version: '1.0'
env: flexible
threadsafe: true
handlers:
  - url: /api
    script: app.js
    secure: always
  - url: '/(.*)'
    secure: always
    application_readable: false
    static_files: "public/\\1"
    require_matching_file: false
    upload: 'public/.*'
automatic_scaling:
  min_num_instances: 2
  max_num_instances: 20
  cpu_utilization:
    target_utilization: 0.5
resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 20

1 Answers1

2

As stated in this answer, the flex environment doesn't support the handlers section in app.yaml. That post also has a couple of examples of how to get this up and running in nodejs.

The second half of your question has a similar answer - you need to implement these redirects in your node app directly.

Patrick Jones
  • 319
  • 2
  • 7