No description
Find a file
2021-04-07 10:02:22 +12:00
public init 2021-04-07 09:38:44 +12:00
src Minimum reproducible 2021-04-07 09:52:59 +12:00
.browserslistrc init 2021-04-07 09:38:44 +12:00
.eslintrc.js init 2021-04-07 09:38:44 +12:00
.gitignore init 2021-04-07 09:38:44 +12:00
babel.config.js init 2021-04-07 09:38:44 +12:00
package-lock.json init 2021-04-07 09:38:44 +12:00
package.json Minimum reproducible 2021-04-07 09:52:59 +12:00
README.md Bug details in readme 2021-04-07 10:02:22 +12:00
tsconfig.json init 2021-04-07 09:38:44 +12:00

Redirect route triggered simply by having a router-link reference it.

Reproduce

  • npm run serve the repo
  • navigate to localhost:8080/spa/about (/spa is the router base)
  • browser will be redirected to / infinitely because of the router-link referencing a redirect route

Expected

The route redirect function will only be run on link click

Actual

The route redirect function is being run on load

Workaround

  {
    path: "/",
    beforeEnter() {
      window.location.href = "/";
    }
  }

Context

I have a project where domain.com/ is a static site. The Vue SPA is being served on domain.com/base. However, there is no content directly on /base, but only on /base/something Therefore, if someone tries to access /base the best user experience is to redirect them out of the SPA ecosystem back to domain.com/. To do this, the / route is set to redirect with location.href = '/', but that is being triggered immediately when a router-link references that route, even if the user doesn't click it.

router-test

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.