Setting application wide HTTP headers in AngularJS

前端 未结 3 886
广开言路
广开言路 2020-12-01 02:59

Is there a way to set the $httpProvider headers outside of angular.module(\'myApp\', []).config()?

I\'m getting an Auth-Token from the serv

3条回答
  •  感情败类
    2020-12-01 03:26

    Adding to above responses of @Guria and @Panga

    config.headers['X-Access-Token'] = $window.sessionStorage.token;
    

    One can use x-access-token in header as JWT(jsonwebtoken). I store JWT in the session storage when a user authenticate first time.

提交回复
热议问题