V
V
Vlad ~2021-04-02 15:12:22
Vue.js
Vlad ~, 2021-04-02 15:12:22

Why am I getting 404 in router vue?

The project has the following structure
App.vue (inside router-view)
through it we get the home component

path: '/profile',
    name: 'days',
    component: () => import(/* webpackChunkName: "days" */ '../views/Home.vue'),
    children: [
      {
        path: '/profile/day/:id',
        name: 'day',
        component: () => import(/* webpackChunkName: "day" */ '../components/Day.vue'),
      }
    ],

inside it there is a child element
, everything works ok, but there is one thing, but
when I get, for example, such a url
http://stream/profile/day/1
, everything is ok, but when I reload the page, it jumps to 404
because of which there may be such a problem

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2021-04-02
@delphinpro

Because your server is not configured.
You need to redirect all requests to the root (to /)

S
shasoft, 2021-04-02
@shasoft

You are not getting the 404 code from the vue route, but from the server. Because there is no such page on the server.
Do as Sergei delphinpro advised you and everything will work.
p so you don't need to redirect all requests to /, but only those that fail, otherwise the resources will not be loaded.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question