Nuxt has a build in render property option, that you can use inside the nuxt.config.js file.
If you want to add Access-Control Headers for static files just use the setHeaders
function.
See https://nuxtjs.org/api/configuration-render#static.
In the background Nuxt uses the serve-static package (also for other options).
Example:
render: {
static: {
setHeaders(res) {
res.setHeader('X-Frame-Options', 'ALLOWALL')
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', 'GET')
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…