serve `service-worker.js` under `.next` folder is not possible any more after upgrading to `9.3.2`
See original GitHub issueBug report
I was making public .next/service-worker.js
with express, but it is not possible anymore. Is there a way to serve this file? I know it because of a security issue but I was hoping to find a way.
Describe the bug
/service-worker.js
404
To Reproduce
Upgrade next to 9.3.2
server.js
server.get("/service-worker.js", function (req, res) {
const filePath = join(__dirname, "./.next/", "service-worker.js");
app.serveStatic(req, res, filePath);
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Angular Service worker (ngsw-worker.js) is not generated in ...
After running "ng build appname," I have a problem in that the Angular Service worker is not generated in the "/dist" folder.
Read more >Fixing the Next.js Service Worker issue - Asap developers
When we create a React app, a Service Worker is invoked by default, so even if we unregister the Service Worker before deploying...
Read more >How to adopt Next.js into your existing application
Learn how you can use Next.js in a pre-existing React application to add server-side rendering to your project.
Read more >Adding a service worker into your Next.js application
After we have our service worker in place, we need to install it and we can do that when the page mounts. Next.js...
Read more >The New Web: Part 3 – Setting Up The Front End ... - Intertech
Further, as a rule, your data in React may not be mutable. When ... It will create a new folder called “client”, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, the config looks like this. You could add the service worker to your .gitignore so you don’t push it accidentally if you are testing something locally.
I had the same issue. My workaround is to set
swDest: ../public/service-worker.js
inworkboxOpts
configuration and now I can access the service worker without rules in my custom server