问题
I am trying to use a service worker on a basic flask app on Google App Engine for Python. From what I understand if I want the service worker to handle all requests on my domain it needs to be in the application root. However I can't figure out how to let GAE allow access to my service-worker.js in the root. I currently get a 404 response when trying to register the service worker. Any help would be much appreciated, thanks.
回答1:
You can configure this via the static_files
option in your app.yaml
, as described in the documentation.
You should probably opt your /service-worker.js out of caching at the same time.
Something like:
handlers:
- url: /service-worker\.js
static_files: service-worker.js
upload: service-worker\.js
expiration: 0m
来源:https://stackoverflow.com/questions/44081610/service-worker-in-root-on-gae