question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The vue-router can't link to a right page in a multi-project or workspace

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

The vue-router can’t go to the right page in the multi-page project with the config below ‘http://localhost:3000/nested/’ can go to the right page but 'http://localhost:3000/nested/userinfo ’ is 404 not found ‘http://localhost:3000/main/’ is 404, but ‘http://localhost:3000/main.html’ can go to page. if this app use vue-router the url is ‘http://localhost:3000/main.html/userinfo’ ?

// vite.config.ts
import { defineConfig } from 'vite';
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';

const port = 3000;
export default defineConfig({
    plugins: [vue()],
    build: {
        rollupOptions: {
            input: {
                main: resolve(__dirname, 'main.html'),
                about: resolve(__dirname, 'about.html'),
                nested: resolve(__dirname, 'nested/index.html'),
            }
        }
    },
    server: {
        port,
    }
});

Reproduction

https://github.com/miniai/vite-multiple-page.git

System Info

  • vite version: 2.0.0-beta.64
  • Operating System: win32-x64
  • Node version: v12.6.0
  • Package manager (npm/yarn/pnpm) and version: 6.9.0

Logs (Optional if provided reproduction)

404 not found

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wgordon17commented, May 6, 2021

Has anyone found a workaround for this? I’m hitting the same issue (only in vite dev). I understand it’s outside the scope of vite itself, and it’s working as expected when I hook it up with my properly configured web server…but it’s pretty inconvenient when doing development work.

1reaction
w2819commented, Feb 18, 2021

I can use config 'historyApiFallback ’ in vue.config.js,but vite.config.ts didn’t has this config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue-router error: TypeError: Cannot read property 'matched' of ...
I'm using vue-cli and simple-webpack boilerplate. When I add vue-router links to my app component I get this error in console. Error in...
Read more >
Build and Deploy a Single Page App with Vue 3 + Vite and Pinia
In this section of our guide, we'll be adding two new dependencies to our project: vue-router and pinia . Let's go ahead and...
Read more >
How To Navigate Between Views with Vue Router
First, create the view that will act as the 404 page. Change into the views directory:
Read more >
Managing Extensions in Visual Studio Code
You can select the extension item to display the extension's details page where ... in a multi-root workspace by using the Extensions: Configure...
Read more >
How to Reuse Vue Components Between Projects - codeburst
Install the component in another project with npm/yarn. Modify the code right from the new project using Bit and update the changes as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found