We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 702d81b commit ff58b59Copy full SHA for ff58b59
nuxt.config.js
@@ -37,7 +37,7 @@ module.exports = {
37
/*
38
** Plugins to load before mounting the App
39
*/
40
- plugins: ['@/plugins/vuetify'],
+ plugins: ['@/plugins/vuetify', '@/plugins/axios'],
41
42
43
** Nuxt.js modules
plugins/axios.js
@@ -0,0 +1,14 @@
1
+/**
2
+ * redirect the admin panel to the homepage in-case of token expiry
3
+ * @param {[type]} options.$axios [description]
4
+ * @param {[type]} options.redirect [description]
5
+ * @return {[type]} [description]
6
+ */
7
+export default function({ $axios, redirect }) {
8
+ $axios.onError(error => {
9
+ const code = parseInt(error.response && error.response.status)
10
+ if (code === 500 && error.response.data.message === 'Token has expired') {
11
+ redirect('/')
12
+ }
13
+ })
14
+}
0 commit comments