The problem of SPA's direct access to url

all I do is that spa, directly accesses localhost:8080/.
but if the browser directly inputs a url, which is localhost:8080/login, and then requests directly to the backend server, it will come back to 404.As the spa backend certainly does not know that login is all handled by the front end, what method should be used to solve this situation?!
for ideas and related keywords, thank you

background is express, preceded by vue.js

May.26,2021

ide/essentials/history-mode.html" rel=" nofollow noreferrer "> https://router.vuejs.org/zh/g.


route pattern is replaced by hash


configure hash route, so that you will not go to the backend. If you are using vue-router, hash route should be the default. Colleague, you also need to configure a default route when configuring a route, so if you can't identify it, you can redirect directly to another path


.

you are using router's history mode, and changing it to hash is a way, so that the foreground page does not have localhost:8080/login url, and becomes localhost:8080/-sharplogin

.

another way is to intercept 404 requests on server. The html file on the home page is returned by default


requires backend cooperation. spa has only one page, while visiting other pages must be 404 , so the backend can redirect to index.html directly after 404.

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-1e5a158-45560.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-1e5a158-45560.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?