I am planning to convert a django project to Progressive Web App. I am not being able to figure out where to put the service_worker.js and manifest.json files in my django project. I've tried the following:
myproject/
|__app1
|__app2
|__manage.py
|__manifest.json
|__service_worker.js
and then tried to register the service worker from html file using relative path ../../../service_worker.js. That didn't work. It showed this error: "A bad HTTP response code (404) was received when fetching the script."
Another approach I tried is to put the service_worker.js and manifest.json in the static folders:
myproject/
|__app1/
|__static/
|__app1/
|__service_worker.js
|__manifest.json
|__app2
|__manage.py
and access those using {% static 'app1/service_worker.js' %}. The problem with this approach is that the scope of the registered service_worker.js becomes limited to that static folder. I've seen in one stackoverflow answer that I can explicitly set the scope of the service worker as {scope: '/'}. But, I think there might be a better approach which I am missing. Please let me know if anyone has a solution to this.