Angular - UI Router Routes - HTML5 Mode

你离开我真会死。 提交于 2019-12-02 01:05:21

The issue you have is that your server does not know how to respond to /product/ABC123.

I am currently using node.js for my backend with angular, and to solve this I return the angular app for all routes, not just the usual root route for example.

So you might have used something like this in the past:

app.get('/', ...);

Which would have returned the angular app just for the root route. Now I use something like:

app.get('*', ...);

Which will return the angular app for all routes.


I should have mentioned that this can act as a catch all placed after other routes such as for static files. Another alternative is to mark all the routes you want specifically for the angular app, eg:

app.get('/', ...); app.get('/product/:productId', ...); etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!