So I am using vue-auth with vue-router in Laravel 5.8 app. There is '/' landing page which is shown when I go to base URL i.e: if I have started the server on http://localhost:8000/ it shows the landing page but as soon as I Login and go to http://localhost:8000/ it shows a 404. How to fix it can anybody help? I am pretty new to Vue and Vue Router.
Below is the code snippet of router.js auth.js and app.js
router.js
// Pages
import Login from './components/Login'
import Landing from './components/Landing'
import Home from './components/pages/Home'
// Routes
const routes = [
{
path: '/',
name: 'landing',
component : Landing,
meta:{
auth: false,
guest: true
}
},
{
path: '/login',
name: 'login',
component: Login,
meta: {
auth: false,
guest: true
}
},
// USER ROUTES
// Home ROUTES
{
path: '/home',
name: 'home',
component: Home,
meta: {
auth: true
}
},
]
const router = new VueRouter({
history: true,
mode: 'history',
routes,
})
export default router
auth.js
import bearer from '@websanova/vue-auth/drivers/auth/bearer'
import axios from '@websanova/vue-auth/drivers/http/axios.1.x'
import router from '@websanova/vue-auth/drivers/router/vue-router.2.x'
// Auth base configuration some of this options
// can be override in method calls
const config = {
auth: bearer,
http: axios,
router: router,
tokenDefaultName: 'jwtToken',
tokenStore: ['localStorage'],
rolesVar: 'role',
registerData: {url: 'auth/register', method: 'POST', redirect: '/login'},
loginData: {url: 'auth/login', method: 'POST', redirect: '', fetchUser: true},
logoutData: {url: 'auth/logout', method: 'POST', redirect: '/', makeRequest: true},
fetchData: {url: 'auth/user', method: 'GET', enabled: true},
refreshData: {url: 'auth/refresh', method: 'GET', enabled: true, interval: 30}
}
export default config
app.js
import bearer from '@websanova/vue-auth/drivers/auth/bearer'
import axios from '@websanova/vue-auth/drivers/http/axios.1.x'
import router from '@websanova/vue-auth/drivers/router/vue-router.2.x'
// Auth base configuration some of this options
// can be override in method calls
const config = {
auth: bearer,
http: axios,
router: router,
tokenDefaultName: 'jwtToken',
tokenStore: ['localStorage'],
rolesVar: 'role',
registerData: {url: 'auth/register', method: 'POST', redirect: '/login'},
loginData: {url: 'auth/login', method: 'POST', redirect: '', fetchUser: true},
logoutData: {url: 'auth/logout', method: 'POST', redirect: '/', makeRequest: true},
fetchData: {url: 'auth/user', method: 'GET', enabled: true},
refreshData: {url: 'auth/refresh', method: 'GET', enabled: true, interval: 30}
}
export default config
Thats it!!
mode: 'history',