0

I have my NodeJS application running on port 11000 and AngularJS running on port 9000.

I am using HTML5 mode true in AngularJS and my URL's with #! and redirected to / using this mode. However, when I hit refresh, it gives 404.

I do have in my index.html.

As per the link: Angular ui-router pressing refresh causes 404 error. Before pressing the reload/refresh, the url works fine without the hashbang. When I manually add /#!/, it gets redirected to the right path.

The problem needs to be handled server side using app.use(*, callback) but since the server is running on port 11000, the request never really reaches there. Am I missing out on something fundamental here? I tried putting in the star wildcard for all routes in node js but that didn't help.

8
  • You should handle the request on 9000 port i.e. on which server angular application is running Commented Sep 9, 2017 at 11:31
  • Of course, I have a route matching the route in ui-router. It works the first time but not on page reload. Commented Sep 9, 2017 at 11:32
  • On which development server you are using it is webpack dev server or something else Commented Sep 9, 2017 at 11:33
  • I am using grunt Commented Sep 9, 2017 at 11:34
  • if you are using grunt-dev server then this should be handled there Commented Sep 9, 2017 at 11:36

1 Answer 1

1

Actually you are running two separate application one is on node server and another is on local 'grunt-dev server'. So in single page application routing is handled on client side js but when you refresh for a route then initially there is no js loaded to handle the routing and it makes a get request for the same to the server but there is no handling for the same so it gives 404. You have to do config in the grunt-file for handling the such routes.

Sign up to request clarification or add additional context in comments.

Comments

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.