In vue-router history mode, the get request is not sent to the background

in order to avoid ugly URL, using history mode when using vue-router, the express, used at the back end is then configured with the following
const history = require ("connect-history-api-fallback");

according to the official website.

app.use (history ());
app.use (express.static (path.join (_ _ dirname,". / client/dist");

but for the get request issued by the current end, when the address bar becomes http://localhost:3000/?tab=technology
, the request is not sent, and the index.html file is returned. How can the request be sent correctly? after reading the official documents of connect-history-api-fallback, I still don"t understand it very well. Do you have any advice from the bosses? Or it would be nice to have a Git project to learn. I really don"t know what to do. It"s all right after being configured according to the NGINX on the official website. What on earth is express going to do

?

if it is history mode, configure one more path
{
path:'*',
name: 'index',
component: index
},
complete as follows

export default new Router ({

mode: 'history',
routes: [
    {
        path: '*',
        name: 'index',
        component: index
    },
    {
        path: '/',
        name: 'index',
        component: index
    }
]

})


for beginners, it is recommended to look directly at the code of the project generated by vue-cli


in fact, it is generally set to
const history = require ('connect-history-api-fallback');
/ / this code needs to be on express.static
app.use (history ());
app.use (express.static (path.join (_ _ dirname,'. / client/dist');
), but I can't do it here. It needs to be configured like this:
app.use (history (

{
    htmlAcceptHeaders: ['text/html', 'application/xhtml+xml']
}

));
is mainly to understand what connect-history-api-fallback is going to do and what it means. Refer to this blog post
https://blog.csdn.net/zzl1243.

.
Menu