Forcing a specific page to use HTTPS with angularjs Forcing a specific page to use HTTPS with angularjs angularjs angularjs

Forcing a specific page to use HTTPS with angularjs


I had a similar problem, although was using $routeProvider in a SPA application. What I did was to enforce a redirect inside the controller:

var forceSSL = function () {    if ($location.protocol() !== 'https') {        $window.location.href = $location.absUrl().replace('http', 'https');    }};forceSSL();

This though does reload all resources. However, this happens only once when switching to SSL mode.

Note, the function is actually in a service so can be called from anywhere.

I hope this helps.