I need to set these two custom response headers to enable certain features in my site:
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
How can I do this in a NuxtJS app? I would like to do it for both the dev and production servers.
Thanks Mani for the sharing. I copy the idea to add the below response header on my nuxt, and i test my docker img local and aws ecs's dev and prod env both can work.
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
First create a new js e.g. headers.js, i put under server-middleware because i also have logging file.
headers.js
module.exports = function (req, res, next) {
res.setHeader('X-Frame-Options', 'SAMEORIGIN')
res.setHeader('X-Content-Type-Options', 'nosniff')
next()
}
nuxt.config.js
export default {
serverMiddleware: [
'~/server-middleware/headers'
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With