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

Use Next.js rewrites config #211

Closed mfix22 closed 4 years ago

mfix22 commented 4 years ago

Hey @hanford what are your thoughts on using the new "Custom Routing" rewrites to add this rewrite:

{
  "source": "^/service-worker.js$",
  "destination": "/_next/static/service-worker.js",
  "headers": {
    "Service-Worker-Allowed": "/"
  }
}

rewrite automatically?

hanford commented 4 years ago

Definitely not opposed!

Does this mean you wouldn't need to manually handle the service worker in your now.json?

mfix22 commented 4 years ago

As far as I can tell from the rewrites proposal that shipped, yes!

hanford commented 4 years ago

@mfix22 would you be interested in a PR? I've been really busy lately 😅

mfix22 commented 4 years ago

@hanford I'll try and get to it sometime, but I wouldn't assign me yet in case someone else can take it

kevinwolfcr commented 4 years ago

hey! i added PR #226 to solve this!

mfix22 commented 4 years ago

@iamkevinwolf thank you! However, your PR does not solve the issue I am referring to, which is to let Next.js handle the rewrites, not Now.

In fact, I think I jumped the gun a little in posting this issue originally, since I think Next.js rewrites is still an experimental feature (AFAIK).

@hanford if you want to close this issue, go ahead, and we can reconsider once rewrites becomes a default part of the Next.js API

kevinwolfcr commented 4 years ago

Oh ok got it. But I guess we can still use it as an updated example according to current Now2 API. 🤔

cvolant commented 3 years ago

Rewrites are not experimental anymore. It would be relevant to reopen this.