Reputation: 6108
I know there are some posts about this topic. I have read most of them, but I think I´m not skilled enough to understand what should I do.
I have an AngularJS 1.0.7 web application. I have just configured it to html5Mode to prettify my URLs. My URLs looks nice now, but I got a new problem I hadn´t before the change. When I first load my index page, I can refresh it without problem. However, if I navigate to some other page in example /about and then I refresh the page I get a 404 Error.
For example in this post: Reloading the page gives wrong GET request with AngularJS HTML5 mode I have read that I should rewrite my urls in server side to my entry point, I guess index.html, but I don´t have any idea about what this means and how to do it.
Would anybody be so kind to provide a bit more detailed and practical example?
What does they mean when they talk about the server? I have an Angular application running on an Nginx server that sends requests to a Rails API that runs on a Puma server.
Upvotes: 0
Views: 2052
Reputation: 1278
So the idea is to force Nginx to point all htpp requests to index.html and let the Angular do the routing in your application.
You didn`t post any configuration so here is the most basic:
server {
listen 80;
server_name foobar.com www.foobar.com;
index index.html;
root /var/www/mysite;
location / {
try_files $uri$args $uri$args/ index.html;
}
}
Upvotes: 1