I just started with an angular app using angular-token and a rails back-end with devise-token-auth, I have the next "on-submit" in a sign-in component:
onSubmit() {
this.output = null;
this.tokenService.signIn(this.signInData).subscribe(
res => {
console.log(res)
this.output = res;
this.signInForm.resetForm();
this.router.navigate(['/products']);
}, error => {
this.output = error;
this.signInForm.resetForm();
}
);
}
When checking with Chrome's DevTools, the Sign-In is successful and the back-end returns good credential headers (uid, access-token, client) that I tested with postman. The problem is, when loading the destination page "products", the httpClient call for populating that new page (I put the call in a resolver to not render anything until the "products" call is complete) is not including any auth headers, so of course, I get a 401 non-authorized error, so it appears angular-token is not correctly updating the headers according to the ones I obtained using the .signIn method.
- How do I make sure the headers are correctly sent?
- Where do I check if they are actually arriving to the subscribed "res"
- As it can be seen, I console.logged it and I cannot see any headers in that variable, although I see them in devTools' "network" tab.