My App.yaml configuration file is :
runtime: nodejs12
handlers:
# Serve all static files with url ending with a file extension
- url: /(.*\..+)$
static_files: build/\1
upload: build/(.*\..+)$
# Catch all handler to index.html
- url: /.*
static_files: build/index.html
upload: build/index.html
secure: always
redirect_http_response_code: 301
- url: /static
static_dir: static
When I deploy it doesn't update the frontend. I think the static files are not changing whenever I deploy. Is it caching? I don't know what to do
First, are you deploying to a new version and not migrating traffic to it? In the GCP console, you can go to "App Engine" > "Versions" (https://console.cloud.google.com/appengine/versions) to see your currently deployed versions and it will tell you which one is receiving traffic.
Next, make sure your files actually got deployed. If you go to the "Debugger" in the GCP console (https://console.cloud.google.com/debug), you'll be able to browse what files have been deployed. If you have multiple versions, there is a version dropdown to switch between them, so make sure you are browsing the correct version.
App engine does set the cache period for static assets to 10 minutes if you dont otherwise specify.
https://cloud.google.com/appengine/docs/standard/nodejs/config/appref#runtime_and_app_elements
EDIT: Also, the order of your
handlers:
matters. They are checked in order. So your rule forurl: /.*
is probably capturing all of the traffic you intended to be captured by your rule forurl: /static
Furthermore, I think its a mistake for your catch-all
url: /.*
handler to return index.html. It'd be better to have something likeurl: /index.html
return your index.html and let the rest just 404. You probably have other errors/typo'd urls that you aren't noticing right now.EDIT 2:
I'm actually surprised your current setup ever worked, because in the reference for
app.yaml
it says:https://cloud.google.com/appengine/docs/standard/nodejs/config/appref
So I put together a sample project, this is my project structure:
In
app.yaml
I did a few things.url: /static
first becauseurl: /(.*\..+)$
was capturing/static/css/bootstrap.css
.index.html
becauseurl: /(.*\..+)$
was already taking care of itapp.js
app.yaml:
For
app.js
andpackage.json
i copied them from GAE's "Hello World" example here https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/hello-world/standardapp.js:
package.json:
I ran
npm install
andnpm start
to run it locally, per the instructions in the hello world, but unfortunately that doesnt emulate the behavior ofhandlers:
inapp.yaml
when i deployed it, going to https://my_project_id.appspot.com/index.html did work.