I have the following yaml file for my Google App Engine website.
application: <my-app-id>
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /sitemap.xml
static_files: static/sitemap.xml
upload: static/sitemap.xml
- url: /
static_files: static/index.html
upload: static/index.html
- url: /
static_dir: static
When I test this app using the local server, the file sitemal.xml is accessible by navigating to.
http://localhost:8080/sitemap.xml
However, when I deploy the app, navigating to the following page just redirects me to index.html (it is impossible to download the xml file).
http://<my-domain>.net/sitemap.xml
http://www.<my-domain>.net/sitemap.xml
Why is the local version behaving differently from the deployed version? What can I do to make the file available in the deployed version?
Google App Engine doesn't support naked domains and most likely it's not being redirected correctly. Try accessing it via: http://www.<my-domain>.net/sitemap.xml to see if that works.
It turns out the problem was caused by domain redirection. If I access the application directly, via the following.
http://<app-id>.appspot.com/
Then everything is fine. Apparently something is broken in the way the domain hosting service handles the redirection.
Related
I am setting up URL Maps on our Backend Services with Load Balancer. The issue is that my URL Maps are not working for some reason. When I tried to browse domain.com/path, it shows
The requested URL /bpd was not found on this server.
I do believe I did the correct way, but seems that its still not working.
Please see screenshot below:
[![image][1]][1]
/* - working
/path1 and /path2 - not working, shows error - was not found on this server
app.yaml file:
runtime: python27
api_version: 1
threadsafe: true
service:
handlers:
- url: /
static_files:
upload:
secure: always
redirect_http_response_code: 301
- url: /(.*)
static_files: www/\1
upload: www/(.*)
I also set-up Serverless network endpoint group and connected with Google App Engine for the Backend Services.
Thank you all for your help.
Thanks to your comment, I though I found the mistake. In fact, when you define a URL map in a load balancer, the query path in entry of the load balancer is, by default, forwarded as-is to the backend.
Let's take your case
you have this URL map: <URL>/address/*. Your URL path is /address/*
The backend is <myAddressAppEngine.appspot.com>. It received the request on this path <myAddressAppEngine.appspot.com>/address/*
And it doesn't work because in reality you expect <myAddressAppEngine.appspot.com>/*.
To solve that, you can use advanced mode in the URL map
Start by setting the default backends for any URL and any path
Then add a new path rule and configure it like this, with a path rewrite to /
This question already has answers here:
How do I setup routing for react in GAE? Directly routing to react-router-dom routes via URL fails in GAE on basic create-react-app?
(5 answers)
Closed 3 years ago.
Production ReactJS app, integrates Spotify Web Api (https://developer.spotify.com/documentation/web-api/reference-beta/) using Google App Engine: https://widget-dashboard-app.appspot.com/
All of the routes (/settings, /about, /contact) work as expected BUT when a user tries to log in to Spotify, the redirect path /settings/#access_token=[BIG-LONG-TOKEN]&token_type=Bearer&expires_in=3600 results in this error via GAE:
Error: Not Found
The requested URL /settings/ was not found on this server.
My first thought is that I have an issue in my app.yaml file:
# [START runtime]
runtime: python27
api_version: 1
threadsafe: true
# [END runtime]
# [START handlers]
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
- url: /.*
static_files: build/static/\1
upload: build/static/.*
- url: /settings/.*
static_files: build/static/\1
upload: build/static/.*
# [END handlers]
I've scoured the Interwebs in search of what might be the issue for two weeks. I've read all. the. docs.
Actual result should be: User logs in via Spotify's Web API, and is redirected back to https://widget-dashboard-app.appspot.com/settings/#access_token=[BIG-LONG-TOKEN]&token_type=Bearer&expires_in=3600 and their browser will begin playing music within a few seconds. This works in development.
As it's an SPA with your routing handled by the app, you need a catch-all route that lands on your main index.html. So it looks like your wildcard rule should be this:
url: /.*
static_files: build/index.html
upload: build/index.html
I don't think you'll need the /settings/ one
I am trying to host my HTML page in App Engine. When I am trying to access the webpage with url/index it returns
Cannot GET /index
I have followed the steps mentioned in
https://cloud.google.com/appengine/docs/standard/python/getting-started/hosting-a-static-website
having same file structure as it expects according to the link above.
- my_project
|- app.js
|- app.yaml
|- www
|- index.html
The below is my app.yaml file
# [START app_yaml]
runtime: nodejs
env: flex
service: service_name
# Adding CORS Support
handlers:
- url: /index
static_files: www/index.html
upload: www/index.html
- url: /index
static_dir: www/
- url: /getEndPoint
script: app.js
# [END CORS Support]
# [END app_yaml]
Not sure what am I missing here.
You're following the python 1st generation standard environment documentation, but your app.yaml selects the nodejs flexible environment (and uses statements not supported/ignored in this environment's app.yaml)
Maybe of interest: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment
So you either:
follow the nodejs flexible environment Serving Static Files documentation
switch to the nodejs standard environment (by dropping the env:flex statement and selecting the nodejs10 or nodejs8 runtime) and follow the corresponding Serving Static Files documentation.
If you're unsure which environment you want, go through the Choosing an App Engine Environment guide.
I have an angular js app with following structure
app structure
my app folder look like
app folder
the app does use any back end interaction for now but in future its gonna interact with a separate app engine java project . I want to host this angularjs app to google app engine but I am not able to understand the right configuration . I am more confused how do I set up the app.yaml for google app engine ... and is it necessary to have a main.py file as at present I do not have any handler
If I understand correctly, you would like to host a static web page on app engine, specifically an AngularJS app.
You don't need any server side code and can configure your app.yaml as follows:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
This is assuming you will host your client side code in a www folder and you use a index.html as your index file.
Also take a look at the following guide for hosting a static website [0].
[0] https://cloud.google.com/appengine/docs/standard/python/getting-started/hosting-a-static-website
I'm just getting started with my first app engine site. I followed the hello world sample to get my home page up and running. I added a css file and declared a static handler for it in my app.yaml. Here is the full content:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /css/.*/(.*)
mime_type: text/css
static_files: css/\1
upload: css/(.*)
expiration: "30d"
- url: /.*
script: myapp.app
When I use the Audit feature of the Chrome developer tools, it warns that my CSS file is explicitly non-cacheable. I tried increasing the expiration time, but that didn't help.
Is there anything else I need to do to enable caching for static files? I haven't messed around with any settings in the site dashboard, so it should be using the default settings.
When I run this same test on the SDK against localhost, I get the same warning that none of my CSS is cached and that it's set to be explicitly non-cachable.
When I deploy the app and run the test from .appspot.com, I only get a warning for the jquery CDN link, and all of my CSS files are cached.
Hope this helps.
EDIT: Looks like the files are marked as proxy-cacheable, but I'm still seeing them as non-browser cacheable.