Bearer token doesn't get updated in request (Chrome)
<p>I'm using AngularJS (1.6.1) and created an AuthorizationInterceptor.</p>
<p>When I add the access_token from local_storage to the 'Authorization' header it doesn't get updated in Chrome. It seems Chrome 'cached' the request</p>
<p>The token changes in local-storage but when Chrome does the actual request it always uses the same token (checked with Dev Tools, Postman and Fiddler...)</p>
<pre><code>this.request = function (request) {
   request.headers = request.headers || {};
   if (window.localStorage.getItem('access_token') !== '') {
        alert(&quot;Adding header in request \n \n&quot; + window.localStorage.getItem('access_token'));
        request.headers.Authorization = 'Bearer ' + window.localStorage.getItem('access_token');
   }
   return request;
};
</code></pre>
<p>I tried the following:</p>
<pre><code>this.request = function (request) {
   request.headers = request.headers || {};
   if (window.localStorage.getItem('access_token') !== '') {
        //alert(&quot;Adding header in request \n \n&quot; + window.localStorage.getItem('access_token'));
        request.headers.TEST= 'Bearer ' + window.localStorage.getItem('access_token');
   }
   return request;
};
</code></pre>
<p>Now I'm not setting the Authorization header anymore but a 'TEST' header.</p>
<p><a href="https://i.stack.imgur.com/LRRbX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LRRbX.png" alt="enter image description here" /></a></p>
<p>The test header now has the correct 'access_token' but there is still an 'Authorization' header? I don't know where it's coming from. It's nowhere programmed to add the header.</p>
<p>I also don't know where Chrome gets this access token from. It's one of yesterday. It's not in the request object either...
Also after deleting every saved information of the domain using Chrome settings, Chrome still manages to use an old token.</p>
<p><a href="https://i.stack.imgur.com/wyxrQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wyxrQ.png" alt="enter image description here" /></a></p>
<p>If I reinstall Chrome the bug is solved. Until it happens again...
The bug is not present in Firefox, Edge and Internet Explorer</p>
<p>Did someone had a similar bug?<br />
I'm getting desperate</p>
<p>Sincerly,
Brecht</p>