nuxt-csrf CSRF protection for your Nuxt app
- Install the module
- You will find your CSRF token in a Vuex store module
- Send the token along with any API requests (except:
GET|HEAD|OPTIONS|TRACE
)
- Add
nuxt-csrf
dependency using yarn or npm to your project - Add
nuxt-csrf
tomodules
section ofnuxt.config.js
{
modules: [
// Simple usage
'nuxt-csrf',
// With options
['nuxt-csrf', {
sessionName: 'myCSRFSession',
secretKey: process.env.SECRET_KEY,
headerName: 'X-MY-CSRF-HEADER'
}],
]
}