FG
๐Ÿ”Œ APIs & SDKs

axios doesn't see request headers that I set

Freshabout 8 years ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

Hi, I tried to make a CORS API post call using axios but I've been never able to do that because I must set headers to make a proper call however axios doesn't see the headers I set. For example, This is what I set as URL and Headers; [code block] The request is sent successfully so I don't write the code where I call axios. The problem is I couldn't set the headers. This is the request pic; This is my axiosConfig; Even if I set "Authorization", I don't know why it is not shown in my request.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: axios doesn't see request headers that I set

Low Risk

I'd like to say that I've encountered this error and solved it doing the following: Instead of doing: ` return axios.get(api + '/api/user/getUserInfo', { params: { UserId: 1 } }, config)` Where `config = { headers: { 'Authorization': 'Bearer ' + accessToken } }` I did: `return axios({ method: 'get', url: api + '/api/user/getUserInfo?UserId=

74

Trust Score

6 verifications

100% success
  1. 1

    I'd like to say that I've encountered this error and solved it doing the followi

    Instead of doing: ` return axios.get(api + '/api/user/getUserInfo', { params: { UserId: 1 } }, config)`

  2. 2

    `config = {

    headers: { 'Authorization': 'Bearer ' + accessToken } }`

  3. 3

    `return axios({

    method: 'get', url: api + '/api/user/getUserInfo?UserId=1', headers: { 'Authorization': 'Bearer ' + accessToken } })`

  4. 4

    And it worked. I hope to help someone with this.

    Cheers!

Validation

Resolved in axios/axios GitHub issue #891. Community reactions: 29 upvotes.

Verification Summary

Worked: 6
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

axioshttpapi