[SOLVED] Request Authorization Headers Not Being Sent

Hullo… I have trouble sending headers to my server… It 's a GET request but I can’t seem to get it to work.

 url: END_POINT,
dataType: 'json',
headers: {
  Authorization: `Bearer ${store.state.token}`

my server receives nothing, checking under the network tab, there is an empty authorization header… Is there anything I am doing wrong? I have tried this "Authorization":Bearer ${store.state.token} too but failed.

token is not empty, I can see it in console.log(). I have tried the beforeSend too and failed…


My Apache backend is ‘stupid’ :roll_eyes:, it strips off Authorization headers…
I can’t spend 3 hours figuring this out… I have decided to send the token as part of the data… So solved!

Hi max,
maybe this helps. i assume you use php as backend.

1 Like

Awesome… Tried this but still failed… I tried a custom header like:

headers: {
 'Token' : store.state.token

and added
header("Access-Control-Allow-Headers: Authorization, Token, Content-Type");
for CORS and it worked… But Authorization doesnot work whatsoever… I use JWT Auth, so basically, I validate all requests before releasing no data… I guess this will work

Yes that should work. But its strange that you cannot set auth header

1 Like

Yes… Pretty confusing… Even restarted apache but failed. But it’s ok, we are planning to dump PHP for node, but now, this will work.
@pvtallulah… Thanks so much and congs upon becoming a patron bro, coming soon!


1 Like