Shibankar
Shibankar

Reputation: 846

Angular 2 create status page and access without hash

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

Upvotes: 0

Views: 481

Answers (1)

Capricorn
Capricorn

Reputation: 2089

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/

Upvotes: 0

Related Questions