简体   繁体   English

将 Angular 路由与预定义的服务器端路由同步

[英]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.我对 Angular 相当陌生,过去几天我一直在学习它,但我停滞不前。 On my node js server i have code like this:在我的节点 js 服务器上,我有这样的代码:

     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.单击 url 栏并尝试从那里访问路线可能会引发 404 错误或带我回到家庭路线。 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.在 react-router@3.1.0 中,即使使用 node js 路由,路由也能正常工作,我试图在 angular 中实现同样的目标 抱歉,我的写作既不是英国人也不是美国人。

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繁荣问题解决了,我的节点 js 服务器不再有 E404

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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