Fix CORS in service worker (#342)

* Add crossOrigin to generated <script> elements if CDN is used

* Add CORS headers to darkmode.js

---------

Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
ekzyis 2023-07-05 16:36:00 +02:00 committed by GitHub
parent 69f6f63b9c
commit f417092107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -30,12 +30,23 @@ module.exports = withPlausibleProxy()({
generateBuildId: isProd ? async () => commitHash : undefined,
// Use the CDN in production and localhost for development.
assetPrefix: isProd ? 'https://a.stacker.news' : undefined,
crossOrigin: isProd ? 'anonymous' : undefined,
async headers () {
return [
{
source: '/_next/:asset*',
headers: corsHeaders
},
{
source: '/darkmode.js',
headers: [
...corsHeaders,
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
},
{
source: '/Lightningvolt-xoqm.ttf',
headers: [