Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alphacheck's avatar

vue route not found

I am Building a Vue SPA with Laravel. I have a several route here. if I brows my home route i.e. example.com it working fine. But if I brows other routes i.e example.com/subCate it gives me following error: Not Found The requested URL /subCate was not found on this server.

Following are my codes:

  1. routes/web.php
<?php
Route::get('/{any}', 'SpaController@index')->where('any', '.*');
  1. resources/assets/js
<?php
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import App from './views/App'
import Hello from './views/Hello'
import Home from './views/productList'
import Product from './views/productList'
import ProductDetails from './views/ProductDetails'
import SubCate from './views/subcate'

const router = new VueRouter({
    mode: 'history',
    routes: [
        {
            path: '/',
            name: 'home',
            component: Home
        },
        {
            path: '/hello',
            name: 'hello',
            component: Hello,
        },
        {
            path: '/product',
            name: 'product',
            component: Product,
        },
        {
            path: '/productDetails',
            name: 'productDetails',
            component: ProductDetails,
        },
        {
            path: '/subCate',
            name: 'subCate',
            component: SubCate,
        },
    ],
});

const app = new Vue({
    el: '#app',
    components: { App },
    router,
});
  1. App.vue
<router-link to="/subCate"><a>url to example</a></router-link>
0 likes
2 replies
uF4No's avatar

dont u have to use the name of the route instead of the path?

<router-link to="subCate">url to example</router-link>

alphacheck's avatar

Yes I can use name of the route. But in that case the problem remain same. If I put the url "example.com/subCate " on browser it gives me not found error. Probably it search in laravel main route.

Please or to participate in this conversation.