You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Property 'Authorization' does not exists on type 'AxiosHeaders' after upgrade to 1.2.2 #5416
I'm getting the following error after upgrading axios to version 1.2.2:
TS2339: Property 'Authorization' does not exist on type 'AxiosHeaders | Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>'.
Property 'Authorization' does not exist on type 'AxiosHeaders'
The same snippet of code is working on version 1.2.1:
Reacted by Demianov Mikhail, Filip Bekić, Justas Palumickas, Kevin Kirsche, Andras Lassu, Matthew Wolfe, Justin Gregory, libraxss, Ani Ravi, Atanas Atanasov and 57 more
Reacted by juventusforever and Rich11
Reacted by Rich11
Reacted by Sebastian Trebunak, libraxss, oyal, Adam Mołczan, Allan Colibao, Rich11 and Leo Kim
changed the title [-]Property 'Authorization' does not exist on type 'AxiosHeaders' after upgrade to 1.2.2[/-][+]Property 'Authorization' does not exists on type 'AxiosHeaders' after upgrade to 1.2.2[/+]on Dec 31, 2022
config.headers = { ...config.headers } as AxiosHeaders;
config.headers.set('Authorization', token);
Reacted by spencer5051, Leonardo Dipace, João Vitor Martins Neto, Kieran, Mustafa Irfan TARI, Marian Spoiala, Mandalbayar, Yasin Yusuf, dteknolove, bramvdpluijm and 24 more
Reacted by Tanguy Royere and Bence Németh
Reacted by Dmitry, João Vitor Martins Neto, Alex, Dercilio Fontes, Hwi Kwon, Thibaud Duthoit, Geraldo Luiz, Giorgio Bertolotti, Lucas, Faraz Khan and 2 more
Try something like this if you are using Axios with TS -> (config.headers as AxiosHeaders).set('Authorization', token); it worked in my case.
Reacted by Rui Araújo, yodaka, Yudatadei, Muhammad Zain Ejaz, Jeff Johnson, Samuel Bran, X-lem, Stanislav Zhukovskiy, Josh Buchea and Nikolay Ryazantsev
I am also having this issue - could anyone clarify if this is an intended behaviour after 1.2.2 or is this a "bug" which will likely be fixed in a future release?
Since this is a bug, rather than working around it with casting I chose to use @ts-expect-error so that typescript will complain when it is fixed.
Since the code still functionally worked even though the type didn't say it would, I found this to be the least invasive change while still allowing the upgrade.
Wanted to share in case it helped anyone, thanks for all the time and effort the maintainers and contributors put into this library and its community. Have a great week all 🙂
Reacted by Natalia, Nickman87, Jake Bishop, Sam Hulick, Sam, Stephen Wade, Severin Bahman, Matthew Gill, Danyal Mahmud, Hector Ayala and 1 more
Activity
karlhorky commentedon Dec 30, 2022
@DigitalBrainJS I guess this was introduced in the following line of PR #5375:
And seems like this issue is similar to what's happening in this issue:
AxiosHeaderstypings #5415karlhorky commentedon Dec 30, 2022
Oh, maybe it's already fixed in this PR:
[-]Property 'Authorization' does not exist on type 'AxiosHeaders' after upgrade to 1.2.2[/-][+]Property 'Authorization' does not exists on type 'AxiosHeaders' after upgrade to 1.2.2[/+]AmosSzust commentedon Dec 31, 2022
Having the same issue so following...
kirill-linnik commentedon Dec 31, 2022
same here, rolling back version update so far
tada5hi commentedon Dec 31, 2022
@jasonsaayman would be great if you could create a hot fix release ( semver patch ) with #5420.
xgenem commentedon Jan 2, 2023
Here's how I fixed it
cmario92 commentedon Jan 2, 2023
I locked my version to 1.2.1 for now, until this is resolved
xgenem commentedon Jan 2, 2023
I was in 1.2.1 when it happened. Thought it was fixed in 1.2.2 so I upgraded. Still same issue.
cmario92 commentedon Jan 2, 2023
just checked again, on
1.2.1I don't get this error. only on1.2.2xgenem commentedon Jan 2, 2023
Correct. The following can still be done in 1.2.1
crypt096 commentedon Jan 3, 2023
Try something like this if you are using Axios with TS ->
(config.headers as AxiosHeaders).set('Authorization', token);it worked in my case.ruiaraujo012 commentedon Jan 3, 2023
Thanks, this works for me
DercilioFontes commentedon Jan 3, 2023
I could solve it using the following:
sbahman commentedon Jan 4, 2023
I am also having this issue - could anyone clarify if this is an intended behaviour after 1.2.2 or is this a "bug" which will likely be fixed in a future release?
20 remaining items
karlhorky commentedon Jan 7, 2023
Seems like another new release of
1.2.3is happening here:coo-kiee commentedon Jan 11, 2023
It's not help to me
I sovled it:
kkirsche commentedon Jan 11, 2023
Since this is a bug, rather than working around it with casting I chose to use
@ts-expect-errorso that typescript will complain when it is fixed.Since the code still functionally worked even though the type didn't say it would, I found this to be the least invasive change while still allowing the upgrade.
Wanted to share in case it helped anyone, thanks for all the time and effort the maintainers and contributors put into this library and its community. Have a great week all 🙂
ffxsam commentedon Jan 11, 2023
Wow, today I learned about
@ts-expect-error. Cool!marsDes commentedon Jan 12, 2023
AmosSzust commentedon Jan 13, 2023
Am I missing something or 1.2.3 was not released eventually?
Is there a problem with it?
Thanks
xgenem commentedon Jan 13, 2023
I think it was reverted? Not sure. But for now this should help you
v1.2.2
AmosSzust commentedon Jan 13, 2023
I saw the many fixes in this thread but I was wondering if there's another issue that prevents this fix from being formally released.
Revert axios to v1.2.1
curtizdev commentedon Jan 15, 2023
I tried this and it works for me, you can also try it.
axiosInstance.interceptors.request.use(
async (config) => {
const token = await getItem("jwtToken");
if (config.headers)
(config.headers as AxiosHeaders).set("Authorization",
Bearer ${token});return config;
},
(error) => Promise.reject(error),
);
DercilioFontes commentedon Jan 17, 2023
V1.2.3 was released and fixed it.
karlhorky commentedon Jan 18, 2023
@andreylh can you confirm that
[email protected]fixes the issue? And then close this if it's working now?tada5hi commentedon Jan 18, 2023
Dont't upgrade rash to
v1.2.3, it might cause problems :/#5476
jasonsaayman commentedon Aug 6, 2025
closing as im certain this is fixed