App engine endpoints API - 404 with custom domain - google-app-engine

I'm trying to use custom domain with app engine. Everything works fine with localhost and appspot url. But with custom domain endpoints api doesn't work; the API discovery request (https://cc.mdsarowar.me/_ah/api/discovery/v1/apis/conference/v1/rest) returns Not Found with error code 404.
Here is my app.yaml (full code):
- url: /_ah/spi/.*
script: conference.api
secure: optional
And endpoints api (full code):
#endpoints.api( name='conference',
version='v1',
allowed_client_ids=[WEB_CLIENT_ID, API_EXPLORER_CLIENT_ID],
scopes=[EMAIL_SCOPE], hostname = 'cc.mdsarowar.me')
class ConferenceApi(remote.Service):
"""Conference API v0.1"""
........
Thanks in advance.

As per the docs:
Note: Google Cloud Endpoints does not support custom domains.
Edit
There is an open feature request for this so you may want to star it.

Related

Mapping Google App Engine service to Cloudflare

I'm having an Google App Engine service residing at https://service-dot-myproject.uc.r.appspot.com/
However I want it to be reachable via https://app.mydomain.com
I have set up the DNS for mydomain.com on Cloudflare and added the custom domain mapping in app engine and set up a dispatch.yaml file
- url: "app.mydomain.com/*"
service: service
Is there a way to somehow map
https://service-dot-myproject.uc.r.appspot.com -> https://app.mydomain.com ?
currently https://app.mydomain.com only resolves to defaultservice
The following dispatch.yaml file resolved the issue
dispatch:
- url: "app.mydomain.com/*"
service: service
Also the file must be separatly deployed via:
gcloud app deploy dispatch.yaml

Deploying a service to a subdomain Google App Engine

I have two services in my Google App Engine project: default and betaversion
they are currently, successfully deployed to different domains (e.g., example and otherwebsite), because I can't get the one deployed on the subdomain. what I'd like is for default to be at:
example.com
and for the beta to be at:
beta.example.com
so I only have to maintain 1 domain. I've made and deployed a dispatch.yaml file and added the beta CNAME DNS registration in the app engine settings and with my DNS registrar.
dispatch:
- url: "example.com/*"
service: default
- url: "otherwebsite.com/*"
service: betaversion
- url: "beta.example.com/*"
service: betaversion
beta.example.com works, but it's routing to the default service. I feel like I must be missing something small, but it's driving me crazy. Any help or ideas would be appreciated.
In case this helps anyone, the issue was that my updated dispatch.yaml file was inside of an undeployed version of the app.yaml file in the betaversion service.
If editing the dispatch.yaml file - make sure you also re-deploy the location containing that dispatch file. In my case, deploying it using
gcloud app deploy service-folder/dispatch.yaml
did not work unless I also deployed the service as well
gcloud app deploy service-folder/app.yampl service-folder/dispatch.yaml
It could be that you have not specified the service name in the yaml for the non-default service. If you don't specify a service name, I think it will go to the default service.
In addition, we have a blog post (complete with an example) about this scenario. Maybe something there will help you.

How to proxy an endpoint, using Google App Engine

I used to have an Nginx proxy that would do below :
location /api {
proxy_pass http://www.myapiexample.com;
}
Then if I made a request to my website at www.example.com/api, it would take me to http://www.myapiexample.com.
With the app engine, and I'm using Nodejs as my backend, how I can achieve the same?
Can't find anything in the docs
UPDATE : If I'm understanding correctly, I can't have my Nginx anymore, so I need to find a way to have the same proxying functionality with App Engine.
You can use dispatch.yaml configuration file if both of your web and api modules are on app engine. dispatch.yaml sends incoming requests to a specific service depending on the path or hostname in the URL.
dispatch:
# Default service serves simple hostname request.
- url: " example.com"
service: default
# Send all api traffic to the api backend.
- url: "*/api/*"
service: api-backend
You can read more about how to use dispatch file.
If your api module is not on app engine you can redirect requests on application level
dispatch:
# Send all api traffic to the api backend.
- url: "*/api/*"
script: router.py
You can write your routing code in router.py something like
class RouteHandler(webapp.RequestHandler):
def get(self):
self.redirect("http://www.myapiexample.com;", True)

How to stop mixed Content browser Error when calling App Engine Flexible Environment API?

I'm getting this error in browser:
Mixed Content: The page at 'https://{my-site}' was loaded over HTTPS, but
requested an insecure XMLHttpRequest endpoint 'http://{my-api}'. This request
has been blocked; the content must be served over HTTPS.
I know I need to allow https some how. The application uses Gunicorn to run the application on custom Google App Engine Flexible Environment. It also uses flask. Here is my app.yaml:
runtime: custom
env: flex
service: flex-module
entrypoint: gunicorn -b :$PORT main:app
Is it possible to change some setting in the Extensible Service Proxy to allow https in App Engine? Or do I need to get an ssl certificate and key and add the following to my app.yaml:
gunicorn -w3 --certfile=server.crt --keyfile=server.key test:app
Also i'm not sure if i need to add this to a gunicorn.conf.py as in this documentation:
forwarded_allow_ips = '*'
secure_scheme_headers = {'X-APPENGINE-HTTPS': 'on'}
Thanks
As stated in the documentation, Google does not issue SSL certificates for double-wildcard domains that are hosted at appspot.com:
Note: Google recommends using the HTTPS protocol to send requests to your app. Google does not issue SSL certificates for double-wildcard domains that are hosted at appspot.com. Therefore, HTTPS requests must use the string "-dot-" as the URL notation, instead of "." for separating subdomains. You can use the simple "." URL notation with your own custom domains and other HTTP addresses. For more information, see the HTTP and HTTPS examples in the following sections.
So to allow API requests over https and avoid the mixed content browser error, instead of http://version-one.my-app.appspot.com I needed to send request to: https://version-one-dot-my-app.appspot.com
To make HTTPS calls, enable the ssl library for your app by adding the following configuration to the app.yaml file:
libraries:
name: ssl
version: latest
https://google-auth.readthedocs.io/en/latest/user-guide.html

How can I use "login: required" on a Google App Engine app using a custom domain?

I have a Python GAE app on a custom domain. When I add login: required to any handler, the site redirects to the app's appspot.com domain instead of my custom domain. The functionality of the site isn't affected, and all handlers and routes continue to work as expected — just on the appspot.com domain instead.
Example snippet from the app.yaml below. mydomain.com works fine with the custom domain, mydomain.com/test and any other handlers redirect to the appspot.com domain after authentication (myapp.appspot.com/test).
- url: /
script: main.application
- url: /test
script: main.application
login: required
- url: /.*
script: main.application
login: required
Is this a configuration issue with how App Engine is handling the domain, or is this an issue with the redirect used by the login: required setting?
You need to set Authorized redirect URIs in your Developer Console (under API | Credentials) to your custom domain rather than the default appspot.com. So the requests coming from the custom domain would be 'called-back' to the custom domain as well.
Take a look on the attached screenshot on how this is configured for my application.
[]

Resources