V
V
Vladimir Kokhan2021-08-07 10:50:49
Vue.js
Vladimir Kokhan, 2021-08-07 10:50:49

How to set up Laravel + Vue 3 routing?

Having trouble with routes in Laravel 8 & Vue 3. Basically, routing works fine, here is my routes file:

import {createRouter, createWebHistory} from 'vue-router'
import Home from "../comonents/Home";
import Articles from "../comonents/Articles";
import Laravel from "../comonents/Laravel";

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/laravel',
        name: 'Laravel',
        component: Laravel
    },
    {
        path: '/articles',
        name: 'Articles',
        component: Articles
    },

]

const router = createRouter({
    routes,
    history: createWebHistory(process.env.APP_URL),
})

export default router;

Everything works if you click on the links. But if you enter the address directly in the browser, it displays a 404 page.
If you use the createWebHashHistory function, everything works, but the hash sign appears in the address bar - #
Read about server settings here - https://router.vuejs.org/ru/guide/essentials /histo... , did as written for Apache, did not help. Wrote hash: false, didn't help either.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question