Axios request fail to authenticate while using headers
See original GitHub issueDescribe the issue Upgrading from 0.18 to 0.19 version is causing an issue in HTTP requests - GET, POST when sending headers like cookie.
Example Code
const requestOptions = {
baseURL: 'http://localhost:3000',
url: `${endPoint}${ids}`,
method: 'GET',
responseType: 'json',
timeout: 100000,
headers: {
VerificationToken: userToken,
Cookie: cookie,
'Content-Type': 'application/x-www-form-urlencoded',
},
};
axios(requestOptions)
.then((response) => {
// Trigger in case, if it is not authenticated
if (typeof response.data === 'string') {
console.log('It is working here');
}else {
console.log('It should Work here');
}
})
.catch((error) => {
});
Expected behavior, if applicable Api should return expected result as it was giving in ver 0.18.0`
Environment:
- Axios Version [e.g. 0.19.0]
- OS: [e.g. OSX Mojave]
- Browser [e.g. Chrome [Electron] ]
- Electron Version [e.g. 4.0.4]
Additional context/Screenshots It is working flawless in ver 0.18.0, but not in ver 0.19.0 if we hit request (GET, POST) that requires headers.
Issue Analytics
- State:
- Created 4 years ago
- Comments:17
Top Results From Across the Web
Axios authentifaction request fails to send header to Spring Boot
I've tried to do it before with simple sending email and password as parameters of GET request and it worked fine, but now...
Read more >axios not sending cookie | The AI Search Engine You Control
Trying to make requests and send cookies along with it using React and Express. ... axios/axiosAxios request fail to authenticate while using headers#2245....
Read more >Using Axios to set request headers - LogRocket Blog
We can use Axios interceptors to automatically set the Authorization header for all requests:
Read more >How to Perform HTTP Requests with Axios – A Complete Guide
Error Handling; POST JSON with Axios; Transforming Requests and Responses; Custom Headers for Request; Config Defaults; Intercept Requests ...
Read more >Making HTTP requests with Axios - CircleCI
In this response, you get an object of the data that you are expecting, the status code sent back by the server, a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closed due to stale. And feel free to open a new issue if someone met similar problem.
@feed4rz It should be related to #2567 and will be fixed in #2844.
I am having the same problem.
On version 0.18.1 I was able to pass array of cookies
['a=b', 'c=d', ...]
to headers option:And it produced a valid cookie string in headers:
But since version 0.19.0 things have changed:
Array of cookies is not getting formatted anymore. Is this a bug or a feature?