How to request anonymously via Axios?
See original GitHub issueI want to send a GET request to a url via axios.
It seems the website can recognize me via cookies and is redirecting the url to a page where logged in users are moved to.
I want to send a request as if I were doing it from an incognito tab
I have tried using withCredentials: false
config.
This does not seem to have any effect with true
or false
in my case.
axios({
url : url,
method: 'get',
maxRedirects: 15,
headers: {
'Content-Type': 'text/html',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods':'GET',
},
withCredentials: false, // without cookies so no login
})
.then((res) => {
console.log("Response", res.data)
})
.catch((err) => {
console.log("Error with fetch: ", err)
})
});
- Axios version: 0.19.0
- Environment: Browser
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:18
Top Results From Across the Web
How to request anonymously via Axios? - Stack Overflow
I have tried using withCredentials: false config. This does not seem to have any effect with true or false in my case. axios({...
Read more >Contact Us - Axios
If you're having trouble subscribing to or unsubscribing from Axios newsletters, or running into issues with our website, please reach out to our...
Read more >All You Need to Know About Axios - Pluralsight
This guide takes a deep dive into some cool features of Axios like making concurrent requests, consuming arrays, and more.
Read more >How to handle errors with Axios request - Educative.io
Line 8: Use the get method of the axios object to make a get request. The URL provided to the get method points...
Read more >Axios vs. Fetch API – Which is Better For HTTP Requests?
The response data is available as a JSON by default, hence we can immediately access it using the data property. It uses XMLHttpRequest...
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
Any updates on the issue, we’re in the same situation, and fetch works perfectly with
credentials: 'omit'
. Our situation is that we have two applications under the same origin; One usesJWT
and the other authenticates usingCookies
, and we don’t want to include Cookies in the one with JWT but it just simply doesn’t work.This gets more problematic since Axios automatically includes Cookies, if we wanted to use Axios for things like Upload requests and showing progress which currently
fetch
doesn’t support, we’re completely out of options. This basically renders the entire token authentication obsolete in our other app.I understand that this is a limitation of
XHR
but does this mean that I’m completely stuck withfetch
?Had the same problem and found out something new: Axios seems to always add the “Cookie” header when the request goes to the same origin. But it does not automatically add the “Cookie” header when you do a valid CORS request.
Which is strange. And yes the withCredentials configuration variable doesn’t seem to have any effect on this at all.