javascript - Redirect to url with auth header -


i'm trying redirect protected resource. when press login button posts unprotected login api , returns token.

the other routes expect header "authorisation: bearer token" kind of deal, don't know how set header when redirect protected resource:

console.log("success logging in, token retrieved.."); window.localstorage.setitem('token', data.token); window.location.href = '/admin/'; // + '?token='+ data.token; 

i pass token in query, that's bit ugly in opinion have handle endpoint differently how others handled... don't want have use cookies.

is there way add header? maybe i'm going wrong...

the short answer is, can't this. have use query param.


Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -