I know removing hash from AngularJS is pretty straightforward but the problem is that the backend is in Django.
So, the app works unless the page is refreshed using “F5”.
so, http://127.0.0.1:8000/account
works if the button is clicked but refreshing the page gives me Page not found
as the server searches for it in urls.py
file
Can someone please suggest me any fix for this ?
2
Answers
Everything is right. When you refresh the page, firstly request gets processed on the server (and goes to django router). So server should know that it should return your angular page for this URL.
Let’s assume that your page that contains Angular application lives on view called
index
. Then just point this url to it:or point all urls to your view (in case you don’t need any other url’s to be processed without angular):
or something like
You’re not alone with this issue: see this and this.
So as you can see, it’s not Django-specific trouble, but some general client-server workflow.
Use Locationprovider instead of routeProvider and enable html5 to true.
https://docs.angularjs.org/api/ng/provider/$locationProvider