0
votes

I setup a Flask app on Google App Engine as a Flex project. When I browse to https://{project-id}.appspot.com everything is working fine and I can use the app without a problem. Why am I getting a 404?

I setup a custom domain as host.mydomain.io

gcloud beta app domain-mappings list

ID                     SSL_CERTIFICATE_ID  SSL_MANAGEMENT_TYPE  
host.mydomain.io       5270000             AUTOMATIC

Then I setup my dns to point to ghs.googlehosted.com

nslookup host.mydomain.io

Non-authoritative answer:
host.mydomain.io    canonical name = ghs.googlehosted.com.
Name:   ghs.googlehosted.com
Address: 172.217.0.115

However I always get a 404 and here are the logs

gcloud app logs tail -s default

2018-01-25 03:06:32 default[20180124t211951]  "GET /" 404
2018-01-25 03:06:36 default[20180124t211951]  "GET /" 404

Yet when I browse using the https://{project-id}.appspot.com address it works fine

2018-01-25 02:31:55 default[20180124t211951]  "GET /" 200

app.yaml

entrypoint: 'gunicorn manage:app -w 4 -b :$PORT'
env: flex
runtime: python
env_variables:
  FLASK_CONFIG: "production"
1

1 Answers

0
votes

I found the problem was coming from my Flask configuration and not from Google App Engine

In my Production configuration I had this:

SERVER_NAME = "{project-id}.appspot.com"

This was causing Flask to return the 404 , not App Engine.

Changing it to

SERVER_NAME = "hostname.mydomain.io"

Fixed it for me.