Skip to content

Instantly share code, notes, and snippets.

@himetani
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himetani/d469ce9c4de6111a03ad to your computer and use it in GitHub Desktop.
Save himetani/d469ce9c4de6111a03ad to your computer and use it in GitHub Desktop.
angular.module('myApp', ['ui.bootstrap', 'ui.router'])
.config(function($locationProvider, $stateProvider, $urlRouterProvider, $httpProvider){
$locationProvider.html5Mode({
enabled: true,
requireBase: false
})
$urlRouterProvider.otherwise('/login')
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
$httpProvider.interceptors.push(function($q, $location) {
return {
response: function(response) {
return response
},
responseError: function(response) {
if (response.status === 401) $location.url('/login')
return $q.reject(response);
}
};
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment