hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 111 forks source link

Pre-Caching Breaks With Next 9 File Routing #209

Open derekdowling opened 4 years ago

derekdowling commented 4 years ago

Issue

Using Next 9's Dynamic Routing results in page bundle file paths that contain URL characters (e.g. [ and ] in /blog/[postID].js) which should be URL encoded (Next.js does this when using their built-in Link preloader).

Requesting these raw unsafe URL paths, for many systems, can cause the request to be rejected causing pre-caching to error and the Service Worker to crash.

Version: "next-offline": "^5.0.0-beta.11"

Proposed Fix

Presumably there needs to be some sort of encodeURIComponent that we run all of the manifest file paths through. It looks like this can be accomplished with a manifestTransforms option that gets passed to the Webpack Workbox Plugins.

hanford commented 4 years ago

Interesting, yeah we should definitely fix this 👀

ethanmick commented 4 years ago

Any movement on the best way to resolve this? I'm running into the problem now and would love for this to work out of the box instead of having to rename my pages and routes to get around this bug.

hanford commented 4 years ago

@ethanmick I've added some labels to this issue to hopefully raise it, I won't have time over the next couple of weeks to fix this issue specifically, but I'd definitely merge a PR if it contains a fix!