Skip to content
Advertisement

Vue-Router URL from external source always redirects to “/”

I am running Vue 2 directly off the Vue dev server.

I am trying to enter a vue route (vue-router) from an external url.

JavaScript

For some reason I don’t know, vue-router always redirects my request and handles it as if it comes from “/”, which automatically redirects to “/login”

I found a similiar questions here (https://forum.vuejs.org/t/access-to-a-vue-route-from-external-link/107250) but there is no solution to it.

Has anyone knowledge of this problem and knows how to appraoch a possible fix? Thanks in advance!

My routes.js file:

JavaScript

Advertisement

Answer

Switching vue-router mode from ‘hash’ to ‘history’ solved the problem for me.

See here for references on history mode: https://v3.router.vuejs.org/guide/essentials/history-mode.html

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement