I want to set custom header in vue-cli.
The version of vue is 2.5.2.
I tried in main.js:
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
Vue.http.headers.common['Cache-Control'] = 'no-cache, no-store, must-revalidate'
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
But it returns:
Uncaught TypeError: Cannot read property 'headers' of undefined
You can use the devServer option of your vue.config.js which just proxies it to webpack
To set headers:
devServer: {
headers: { "Cache-Control": "no-cache, no-store, must-revalidate" }
}
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