vue-auth: "auth" driver must be set + Cannot read property 'interceptor' of undefined

Hi, sorry, newby in your lib, i thx for your works.

I use vuejs + quasarjs and i try to implement your lib for auth.

i create a boot file with this configuration:

var config = {
  auth: require('@websanova/vue-auth/drivers/auth/bearer'),
  http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
  router: require('@websanova/vue-auth/drivers/router/vue-router.2.x'),
  rolesVar: 'role'
}
export { config }

and i implement in route/index.js

import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)

import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
Vue.axios.defaults.baseURL = process.env.API_URL

import auth from '@websanova/vue-auth'
import config from 'boot/auth'

Vue.use(auth, config)

export default function (/* { store, ssrContext } */) {
  const Router = new VueRouter({
    scrollBehavior: () => ({ x: 0, y: 0 }),
    routes,
    mode: process.env.VUE_ROUTER_MODE,
    base: process.env.VUE_ROUTER_BASE
  })
  return Router
}

in my routes.js

{
    path: '/',
    component: () => import('layouts/Layout.vue'),
    meta: { auth: true, forbiddenRedirect: '/403' },
    children: [
      { name: 'index', path: '/', component: () => import('pages/Index.vue') },
...

I have 2 errors:

1st => “auth” driver must be set but it is set in my boot file

2nd => Cannot read property ‘interceptor’ of undefined sorry, i dont understand…

thx by advance for your help

error image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Same here after update to 3.x TypeError: __auth.http.interceptor is undefined I’m use axios driver

so the setup is a bit different now with es6 modules.

Oh, need to change require to import