#setting headers for static files in local dev
28 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
wdym by that?
i want to be able to add headers to static files, when devving locally
it doesnt seem that nextjs allows you to set content headers
i'm thinking i try and use caddy and get the instance to set the headers
u can serve your selected files trough a route handler and set the header that way
can u tell me your usecase
what u trying to achieve
practical example
there may be a different solution i just dont know what u really trying to do
load sqlite to it has opfs access for a pwa
the problem is, it has to pull in other imports
so simply loading the worker file and returning it is going to be a massive pain in the arse
maybe it'll work, i'll try it
@silk scaffold you can try using the headers option in next.config.js: https://nextjs.org/docs/app/api-reference/next-config-js/headers
yeah, i am, but it that doesnt work
i've looked and a lot of posts (albeit old so maybe somethings changed) states that next doesnt add headers to static files
but maybe if it does now, there's something wrong with my headers config
hrm.. it does seem that those headers arent being sent at all
jesus christ, it seems like that next simply was ignoring my next.config.js file
no idea why
but put it in middle ware... and now i have persistent sqlite store
so for anyone wondering...
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const response = NextResponse.next()
response.headers.set( 'Cross-Origin-Opener-Policy', 'same-origin');
response.headers.set( 'Cross-Origin-Embedder-Policy', 'require-corp');
return response;
}```