MoSheikh
MoSheikh

Reputation: 789

Google App Engine - 404 Error when using Custom Domain from Google Domains

I have a skeleton Google App Engine running on the URL provided by GAE in the format of "myproject.appspot.com". I have two services - one running a backend Node/Express server, and another for a React front-end. The backend service has url "api-dot-myproject.appspot.com" and the front end "client-dot-myproject.appspot.com". I have independently deployed each service along with the root-level dispatch.yaml, and have gotten these GAE-provided urls to work. When I go to the URLs provided by Google, my deployed services work as intended. However, I've also tried used a custom domain from Google Domains which is causing me trouble. I've followed the instructionss provided by Google - I first bought the domain from Google, then added it to Google App Engine. My GAE app then provided me with A, AAAA, and CNAME records to add to my Google Domains "Custom resource records" which I did.

Domains

I then waited over 24 hours before trying to access mydomain.app (the domain name I purchased). However, attempting to access the page results in a 404 error.

404

I've been trying to figure this out for a while now, and I've searched through every previous stackoverflow question on this topic but wasn't able to resolve it. Any help would be greatly appreciated.

dispatch.yaml:

dispatch:
  - url: "*client-dot-myproject.appspot.com/*"
    service: client
  - url: "*mydomain.app/*"
    service: client
  - url: "*api-dot-myproject.appspot.com/*"
    service: api
  - url: "*/*"
    service: client

api.yaml

runtime: nodejs12
service: api

handlers:
  - url: /api/
    script: auto
  - url: /
    script: auto

client.yaml

runtime: nodejs12
service: client

handlers:
  - url: /static/js/(.*)
    static_files: build/static/js/\1
    upload: build/static/js/(.*)
  - url: /static/css/(.*)
    static_files: build/static/css/\1
    upload: build/static/css/(.*)
  - url: /static/media/(.*)
    static_files: build/static/media/\1
    upload: build/static/media/(.*)
  - url: /(.*\.(json|ico|png))$
    static_files: build/\1
    upload: build/.*\.(json|ico|png)$
  - url: /
    static_files: build/index.html
    upload: build/index.html
    http_headers:
      Access-Control-Allow-Origin: "*"
  - url: /.*
    static_files: build/index.html
    upload: build/index.html
    http_headers:
      Access-Control-Allow-Origin: "*"

Upvotes: 1

Views: 1093

Answers (1)

MoSheikh
MoSheikh

Reputation: 789

Truly one of the dumbest mistakes - I had switched over gcloud projects at some point and forgot to reinitialize with gcloud init.

Upvotes: 2

Related Questions