0

I am using Webpack and building multiple angular apps. I am having some issue with routing. This issue only comes when i have $locationProvider.html5Mode(true); in my angular code.

Let say my base URL is abc.com

App 1: abc.com/app1

App 2: abc.com/app2

Now lets say I am on one of these and go to a sub route of any of these app.

abc.com/app1/sub-route1 or abc.com/app2/sub-route2

This scenario works fine. The issue comes when I do refresh or reload from browser. In that case it redirects to abc.com rather than staying on

abc.com/app1/sub-route1 or abc.com/app2/sub-route2

This does not happen if I use $locationProvider.html5Mode(false);

mechanicals
  • 685
  • 3
  • 14
  • Take a look on that question it might be useful for you http://stackoverflow.com/a/16570533/5452965 – codtex Apr 19 '17 at 12:35
  • @sand : thanks for the link. currently I am using Webpack dev-server and running it on localhost. any clues as to what can i do to fix this in webpack ? – mechanicals Apr 19 '17 at 12:45
  • Take a look on that link http://stackoverflow.com/a/34125010/5452965 or search in the web how to redirect all the traffic to `index.html` – codtex Apr 19 '17 at 12:50
  • @sand: thats the problem. I don't want all traffic to be redirected to one index.html. If it belongs to 2nd app then it to load the abc.com/app2/sub-route2 or otherwise if its first app then to abc.com/app1/sub-route1. I'll try to look into webpack to see if there is a way to configure this. – mechanicals Apr 19 '17 at 12:58

0 Answers0