简体   繁体   中英

Syncing Angular routes with predefined server side routes

am fairly new to Angular and ive been it learning for the past few days but ive come to a stand still. On my node js server i have code like this:

     app.get('/account/dashboard', (req, res) => {
        res.render('dashboard_angular'):
     }

when i access the route, the browser url bar looks like this

       localhost:3000/account/dashboard

and after a second the angular router kicks in and changes it to

       localhost:3000/#/

click on the url bar and trying to access a route from there can either throw a 404 error or take me back to the home route. Please is there a work around for this? so i can have the url like this

        localhost:3000/account/dashboard/#/

In react-router@3.1.0, routing works fine even with node js routing, am trying to achieve the same thing in angular Sorry about my writing, am neither british nor american.

I found my issue. I changed the

    <base href="/" />

to my current server route which was like

    <base href="/account/dashboard/" />

and boom problem solved, no more E404 from my node js server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM