Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing ignore set withCredentials false #1852

Closed
wants to merge 7 commits into from
Closed

Conversation

tonwe
Copy link

@tonwe tonwe commented Oct 26, 2018

Explicit to set a true or false setting.
if (typeof config.withCredentials !== 'undefined') {
request.withCredentials = !!config.withCredentials;
}

@kimihiro64
Copy link

@LcTwisk Can someone please merge this? An invalid cookie got accidentally placed in cookie jar and now all my api requests fail...

@waeltken
Copy link

This is looking good! Looks like i need this too... 👍

@kimihiro64
Copy link

Bump @waeltken @emilyemorehouse

This has been sitting here for months, we go live in a month and this is still causing issues if I don't hack this patch in every build...

@gokhandoslu
Copy link

until this pull request completed, you can use the workaround below

create a file named postinstall.sh and add the codes below

#!/usr/bin/env bash

find ./node_modules/axios/lib/adapters/xhr.js -type f -exec sed -i '' -e 's|Add withCredentials to request if needed|Add withCredentials to request if needed. Explicit to set a true or false|g' {} \;
find ./node_modules/axios/lib/adapters/xhr.js -type f -exec sed -i '' -e 's|if (config.withCredentials) {|if (typeof config.withCredentials !== "undefined") {|g' {} \;
find ./node_modules/axios/lib/adapters/xhr.js -type f -exec sed -i '' -e 's|request.withCredentials = true;|request.withCredentials = !!config.withCredentials;|g' {} \;

add a postinstall script into package.json
"postinstall": "sh postinstall.sh"

Copy link
Collaborator

@Alanscut Alanscut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! this will fix #1837

if (config.withCredentials) {
request.withCredentials = true;
// Add withCredentials to request if needed. Explicit to set a true or false
if (typeof config.withCredentials !== 'undefined') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the isUndefined function of utils.

axios/lib/utils.js

Lines 84 to 86 in 8414664

function isUndefined(val) {
return typeof val === 'undefined';
}

@bxjx
Copy link

bxjx commented Dec 5, 2019

Bump on this please! Just hit this issue and am having to use this patch (thanks @gokhandoslu !).

@tonwe @Alanscut, happy to redo pull request if it's stuck waiting on that feedback?

bxjx pushed a commit to bxjx/axios that referenced this pull request Dec 5, 2019
bxjx pushed a commit to bxjx/axios that referenced this pull request Dec 5, 2019
bxjx pushed a commit to bxjx/axios that referenced this pull request Dec 5, 2019
@bxjx
Copy link

bxjx commented Dec 5, 2019

If it helps, I've created a new PR with the feedback #2591. Thanks to everyone on this thread for solutions!

@chinesedfan
Copy link
Collaborator

Closed in favor of #2582. Apologize for the late response.

@chinesedfan chinesedfan closed this Dec 7, 2019
@axios axios locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants