Reputation: 32104
I'm working on an angular 1.5.0-rc0 project.
I'm using angular-route with ng-view with the following configuration:
app.config(['$routeProvider','$locationProvider',
function($routeProvider,$locationProvider) {
$routeProvider.
when('/',{
templateUrl: 'views/index.html',
controller: 'IndexController',
}).
when('/login', {
templateUrl: 'views/login.html',
controller: 'LoginController'
}).
when('/cocktail/:cocktail_name', {
templateUrl: 'views/cocktail.html',
controller: 'CocktailController',
}).
when('/add-drink',{
templateUrl: 'views/add-drink.html',
controller: 'AddDrinkController',
}).
when('/add-cocktail',{
templateUrl: 'views/add-cocktail.html',
controller: 'AddCocktailController',
controllerAs: 'addCocktail'
}).
when('/admin-drinks',{
templateUrl: 'views/admin-drinks.html',
controller: 'AdminDrinksController',
controllerAs: 'adminDrinks'
}).
when('/login',{
templateUrl: 'views/login.html',
controller: 'LoginController',
controllerAs: 'login'
}).
otherwise({
redirectTo: '/'
});
I want to check if users are browsing using https or http. and in case they browse /login
using http I want to redirect them to https.
how can i do that ?
Upvotes: 0
Views: 246
Reputation: 761
I would do it server side before the site loads your JS. I have done this in an angular app in the past and it is more secure to do it in PHP or Apache. Here is a PHP example: Redirecting from HTTP to HTTPS with PHP
Upvotes: 1