0

I have an angular project where the routing is working absolutely fine with HashLocationStrategy.

Now I have to create a health status page which needs to be accessed without the '#' in the URL. The requirement is for my Global Load Balancer to be able to simply access this page and if it returns http 200 then only the request will come.

If the DNS is like abc.com then I need something like abc.com/status instead of abc.com/#/status

Protozoid
  • 1,207
  • 1
  • 8
  • 16
Shibankar
  • 806
  • 3
  • 16
  • 40
  • Possible duplicate of [Angular 2 Remove Hash (#) from the URL](https://stackoverflow.com/questions/41687562/angular-2-remove-hash-from-the-url) – Protozoid May 23 '18 at 08:39
  • Actually not. I know with path location strategy we can remove hash. But that will give 404 on page refresh and need some tweaks on web server to fix that. I am using PaaS and can't do anything on the web server site – Shibankar May 23 '18 at 08:47
  • The "teaks" would be [mod_rewrite](https://www.google.com/search?q=mod_rewrite) url redirecting. Try looking for that in your PaaS Provider's documentation – Capricorn May 23 '18 at 08:52

1 Answers1

0

This does not sound possible. As soon as the angular app itself is loaded, your server already returned a successful http response. Otherwise the angular app itself would not show up in the browser.

So your Global Load Balancer will simply query that angular page and load the HTML source code which usually bootstraps the angular app in the browser. This happens every time, no matter whether your angular app after bootstrapping will show a success or error status.

To report the "status" via HTTP status codes you have to use server side checks and code. Maybe use the REST endpoint your angular app is querying directly.

Sources: https://angular.io/guide/bootstrapping, https://dev.opera.com/articles/http-basic-introduction/, https://dev.opera.com/articles/http-response-codes/

Capricorn
  • 2,061
  • 5
  • 24
  • 31