Usage example for the Nuxt Custom Header package.
Everything is in the last commit of this repo.
yarn add nuxt-custom-headers
In the nuxt.config.js
, add the module name to the loaded modules:
/*
** Nuxt.js modules
*/
modules: [
'nuxt-custom-headers',
],
In your page component, add a function named httpHeaders
to the script part:
export default {
components: {
Logo
},
httpHeaders: () => ({
'Cache-Control': 'max-age=60, s-maxage=90, public',
'X-My-Header': 'Anything you could need'
})
}
You can see in this screenshot the custom headers Cache-Control
and X-My-Header
in the response headers.
# install dependencies
$ yarn install
# serve with hot reload at localhost:3000
$ yarn run dev
# build for production and launch server
$ yarn run build
$ yarn start
# generate static project
$ yarn run generate
For detailed explanation on how things work, checkout Nuxt.js docs.