Thusila Bandara
Thusila Bandara

Reputation: 293

How to configure app.yaml file for node react project in google app engine

I'm developing an application using react js and nodejs.When I run the application in local machine it works properly as a example

localhost:3000/AboutUs
localhost:3000

When I refresh the above URLs, it shows the correct web page. I deploy this application in Google App Engine and when I refresh the below page it shows that the requested URL was not found. Can any one let me know the reason for this?

www.mydomain.com/AboutUs

app.yaml code is as below

runtime: nodejs8
handlers:
- url: /api/.*
# secure: always
# redirect_http_response_code: 301
script: auto
- url: /
static_files: build/index.html
upload: build/index.html

Upvotes: 1

Views: 1982

Answers (1)

Joan Grau Noël
Joan Grau Noël

Reputation: 3192

It's because you don't have a defined handler to direct your /AboutUs URL. You can either add, under handlers:

- url: /AboutUs
  script: auto

Or add a wildcard handler at the end of the url list, for example:

runtime: nodejs8
handlers:
- url: /api/.*
# secure: always
# redirect_http_response_code: 301
  script: auto
- url: /
  static_files: build/index.html
  upload: build/index.html
- url: /.*
  script: auto

It's important to keep the wildcard handler /.* at the end, since otherwise all the URL's will fall under it, and it won't use the other url handlers.

Also you had two spaces missing in the script,static_files and upload tags under the url's, I don't know if it was because of the formatting when copying the app.yaml contents to your answer, but either way, indentation is important in YAML files.

Upvotes: 2

Related Questions