0

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.

1 Answer 1

1

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;
 }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Mmm I´m only half happy. This works! and I can reload any page. However, now some other functionalities has stopped working. In example, modal panels. If I go to a page different that index with a link that opens a modal panel, if I click ok it, the modal panel opens but I´m also redirected to index. What am I missing?
You propably have some error in your Angular.js routes, I cant really tell anything else, without any code from you side, I have really done more than enough :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.