Vue Project Refresh Page 404

the vue project runs normally after local npm run dev. In addition to the normal refresh of the home page, click other page refresh to jump to the 404 page
how to deal with it?

Mar.31,2022

because you use history mode for routing, if you want to run online, you need to set a default page with the back end, which is usually the home page of the current project

.
vue-router default hash mode-uses URL's hash to simulate a full URL, so when the URL changes, the page does not reload.
when you use history mode, URL is like a normal url, such as http://yoursite.com/user/id, which also looks good!
however, to play this mode well, you still need background configuration support. Because our application is a single-page client application, if the background is not configured correctly, users will return 404 when they directly access http://oursite.com/user/id in the browser, which is not good-looking.
so, you need to add a candidate resource that covers all situations on the server side: if the URL does not match any static resources, you should return the same index.html page, which is the page on which your app depends.

ide/essentials/history-mode.html" rel= "nofollow noreferrer" > vue-router


in the devServer of webpack, historyApiFallback: true


lists the following scenarios:

  1. uses webpack, and configures

devServer: {
...
historyApiFallback: true
}

  1. using node framework (egg,express framework) Koa)

/ / vue routing configuration history. Refresh page returns home.index
router.get ('*', 'home.index')

  1. load balancing using nginx

location / {
try_files $uri $uri/ / index.html
}

the ultimate goal is to return the request for refreshing the address to the index page


ide/essentials/history-mode.html-sharp%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90" rel=" nofollow noreferrer "> HTML5 History mode

are you using history mode? the official website gives the answer

.

post your project routing settings, post the console error report


check whether the route is correct


would like to ask, has the landlord solved it? I have the same problem ~

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ffda-2c4d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ffda-2c4d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?