Skip to content

Commit

Permalink
Move SW headers into Next config
Browse files Browse the repository at this point in the history
  • Loading branch information
kmjennison committed Sep 3, 2020
1 parent 3aaf24c commit a159e2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
19 changes: 19 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ const nextConfig = {
].filter(Boolean)
},

async headers() {
return [
{
// This includes the base path: /newtab/service-worker.js
source: '/service-worker.js',
headers: [
{
key: 'Cache-Control',
value: 'no-cache',
},
{
key: 'Service-Worker-Allowed',
value: `${basePath}/`, // e.g., /newtab/
},
],
},
]
},

webpack: (config, options) => {
// Sentry error logging. See:
// https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js
Expand Down
15 changes: 0 additions & 15 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,5 @@
"trailingSlash": true,
"rewrites": [
{ "source": "/v4/(.*)", "destination": "/newtab/$1" }
],
"headers": [
{
"source": "/newtab/service-worker.js",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Service-Worker-Allowed",
"value": "/newtab/"
}
]
}
]
}

0 comments on commit a159e2e

Please sign in to comment.