I'm attempting to append an authorization token onto my GET
request for a list of users. Here's a list of what I've done:
I've looked at this question here in which the answer suggests several things including:
Setting the header directly in the request:
let headers = new HttpHeaders().set('Authorization', 'Token fsadf423qfsadfsda');
return this.httpClient.get('https/my-url/api/users/', { headers: headers });
Cloning the request in the interceptor and appending the headers:
let apiUrl = environment.apiUrl;
const headers = new HttpHeaders({ 'Authorization': 'Token fsadf423qfsadfsda' });
const apiReq = req.clone({ headers: headers, url: `${apiUrl}${req.url}` });
return next.handle(apiReq);
The last point above actually works in Safari but not in Chrome. I selected the Disable Cross-Origin Restrictions in Safari and it worked.
In Chrome I already have installed the CORS Toggle extension and have it running but it doesn't work, nor does running Chrome from the command line like this:
open -a Google\ Chrome --args --disable-web-security
Is this a Chrome specific issue? My version is Version 65.0.3325.181
EDIT
Screenshot of the requests:
EDIT 2
A nice article on understanding CORS