#can it be possible set HEADERS once for all the Response in the /api/route?

9 messages · Page 1 of 1 (latest)

fringe inletBOT
#

🔎 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)

cunning oak
#

Yes you can use the headers() field in next.config.js or middleware for this

nocturne lance
#

but that will be for the page, right

cunning oak
nocturne lance
#

Understood!.. can it be possible to set it directly in the /api/route?

cunning oak
#

I think headers() in config should have a way to configure setting certain headers for certain route patterns, while for middleware it is either the matcher or something like if (req.nextUrl.pathname.startsWith("/api"))

nocturne lance
cunning oak
nocturne lance