2

I am making a web app with node.js using google app engine.

I want to redirect https://MY_PROJECT_ID.appspot.com to mycustome domain. I followed this maual but does not work. What is problem?

https://cloud.google.com/appengine/docs/flexible/nodejs/how-requests-are-routed#routing_with_a_dispatch_file

dispatch.yaml
dispatch:
  - url: 'fermi.me/' //my custom domain 
    service: default

console
gcloud app deploy dispatch.yaml
Configurations to update:

descriptor:      [./nodejs-getting-started/2-structured-data/dispatch.yaml]
type:            [routing rules]
target project:  [XXXXXXX]

Do you want to continue (Y/n)?  Y

Updating config [dispatch]...done.

Even though, dispatch.yaml is successfully deployed, if I executed 'app deploy', Redirection does not work. I already registered domain in Google cloud, and static websites worked.


I found the fundamental problem and it solved.

  1. I already connected to static website with bucket.

    https://cloud.google.com/storage/docs/hosting-static-website

  2. There is a error in web-console in App-Engine domains setting.(Message: "Domain is already mapped to a project in google cloud platform". There is a critical error in this maunal.

https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains

  1. The sample error message. It only appears when you already connect storage static website to domains. error : domain is already mapped to a project in google cloud platform

  2. You can use command-line tool with gcloud beta. Webconsole makes error but commandline works. After you mapped domain, you can now use webconsole. You should add cnames as the maunal above(mapping domains) explains There is a guide.

https://stackoverflow.com/a/46780534/9049333

1 Answers1

1

The dispatch file is only used to direct a request already reaching your app to the appropriate service/module. If the request doesn't match any dispatch.yaml rules it is automatically directed to the default service (making your rule redundant, BTW).

The dispatch file does NOT redirect a request to another domain (or anywhere back outside your app, really). So you're on the wrong track at this point.

You need to take care of such redirection in your application. Possibly relevant starting points for that:

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97