AppEngine: 404 error except home page on deploy server (works fine on local server)

Viewed 112

I'm trying to serve my first static website using google app engine. But it happens that I get 404 not found error except the home page on the deploying server. The strange thing is that everything is fine while running locally with dev_appserver.py, what am I doing wrong?

Here is my app.yaml file:

runtime: go
api_version: go1

handlers:
- url: /$
   static_files: index.html
   upload: index.html

- url: /(.*)/$
  static_files: \1/index.html
  upload: /(.*)/index.html

- url: /(.*\.(gif|png|jpg|js|css))$
  static_files: \1
  upload: .*\.(gif|png|jpg|js|css)$

- url: /.*
  script: _go_app

Here is some logs from command gcloud app logs when I try to access other pages by get request (more specifically here I'm trying url mydomain/art/ which should be directed to art/index.html file in my project repertory):

2018-09-16 10:22:51 default[version]  "GET /art/ HTTP/1.1" 404
2018-09-16 10:22:51 default[version]  "GET /favicon.ico HTTP/1.1" 302
2018-09-16 10:22:51 default[version]  "GET / HTTP/1.1" 204

whereas no problem on local server:

INFO     2018-09-16 10:23:12,434 module.py:880] default: "GET /art/ HTTP/1.1" 304 - 
1 Answers

The /art/ request matches your second handler url.

The upload statement for it is not correct, instead of

upload: /(.*)/index.html

it should be (you have no parenthesis in the actual file path and it should be a path relative to your app/service directory):

upload: .*/index.html

The /favicon.ico request (which many browsers make by default) doesn't match any of your handlers url patterns. Your app appears to be intended to be visited by regular browsers so you may want to add a handler and a matching static file to cover it as well, otherwise such 404s are expected/normal.

The / request is matching the first handler url, the file is found (no 404), but I don't know why it returns a 204. Maybe something with the file content?

Related