A
A
alaskafx2021-11-03 11:50:00
Vue.js
alaskafx, 2021-11-03 11:50:00

How to solve Cannot GET /solm error?

I am using vue-router.
I assembled the project npm run build, when I try to follow the link /solm- I get: Cannot GET /solm

.. with other routes / links the same

Router code:

import Vue from 'vue'
import VueRouter from 'vue-router'
import solm from '../views/solm.vue'
import vega from '../views/vega.vue'
import family from '../views/family.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/solm',
    name: 'solm',
    component: solm
  },
  {
    path: '/vega',
    name: 'vega',
    component: vega
  },
  {
    path: '/family',
    name: 'family',
    component: family
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router


How to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2021-11-03
@Aetae

Wangyu your server is not configured for the type of routing history. Google how to set up your server for SPA (all non-API paths should be wrapped in index.html). Well, or switch the router to mode hash.

S
Sergey delphinpro, 2021-11-03
@delphinpro

In any unclear situation, ALWAYS read the documentation first.
Especially one as good as that of the view.
Here is this section, before enlightenment: https://router.vuejs.org/en/guide/essentials/histo...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question