New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
SW registration failed #127
Comments
Thanks providing a repo where this consistently happens. I'm pretty busy this week but will report back once I have some time to dig in |
i have similar problem |
@hanford hello any update? If you have something in mind, with some guidance I can help to fix it. |
I'm running into the same issue. @MatteoGioioso I would be glad to hear how you solved it ! |
@srosset81 @MatteoGioioso @straxico After looking, you need to either have a custom next.js server or a now.json to handle the service worker request.
The Now 1.0 example is probably easiest for existing Next.js applications, I use it in several other personal projects. The only real changes are the |
I've fixed the issue in the repro case you shared over here: https://github.com/hanford/next-offline-issue-127 Going to go ahead and close issue. Feel free to drop another comment if you have any questions |
I'm a bit confused by this. If the service worker is generated at compile time, why do I need a custom server to serve it? Can't I just point to the pre-generated service-worker.js as a static file? |
@GusRuss89 service workers aren't treated as ordinary JS files. If you're using Now 2.0, you don't need a standalone server, just a now.json. You can see how that works by looking at my personal website |
@hanford Hei, sorry, I forgot to say thanks for the help! |
The link is down and I have this same issue. |
@softwarenacho please open a new issue |
@softwarenacho I have forked it |
thanks @MatteoGioioso ! |
Thanks @MatteoGioioso , I managed to solve it following one off the examples @hanford had published at: I was missing including the service worker in the now configuration. |
For folks who are using workspaces and have the Next.js site in a dir called {
"routes": [
{
"src": "/service-worker.js",
"dest": "/www/_next/static/service-worker.js",
"headers": {
"cache-control": "public, max-age=43200, immutable",
"Service-Worker-Allowed": "/"
}
},
]
} |
@hanford I have the same problem but in a pm2 server in nginx but in now work perfect any idea ?? |
@davisbartce No idea! maybe you need to set something up manually in nginx? |
Hi @hanford, this error still occurs till date. I read through this thread and even checked out your website, It is also broken on there, check the console and you would see |
`const withPWA = require('next-pwa'); module.exports = withPWA({ add this line in next.config.js -> dest: 'public', |
Bug report 馃悶
Hello there, I am trying to use this library with my custom service-worker file, but unfortunately is not working for my use case.
I am receiving this error:
I am using Next.js inside a Docker container
Docker file:
Docker compose
Next.js config
After the build process I can see my service worker file appear correctly in the
.next
folder.Looks like the custom service worker use case is not common, so if there is something wrong in my config, please forgive me 馃檹 .
This is the repo where you can reproduce the error (In this case I have not use Docker): https://github.com/MatteoGioioso/next-offline-sw-error-2
Thanks
The text was updated successfully, but these errors were encountered: