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

Ajax with PUT and CORS #4003

Closed
Agraphie opened this issue Aug 10, 2018 · 3 comments · Fixed by #5702
Closed

Ajax with PUT and CORS #4003

Agraphie opened this issue Aug 10, 2018 · 3 comments · Fixed by #5702
Labels
feature PRs and issues for features help wanted Issues we wouldn't mind assistance with.

Comments

@Agraphie
Copy link

Bug Report

Current Behavior
Ajax PUT is not sending the cookie in the header.

Reproduction

  • Create a simple request and have a cookie in your store
  • Try ajax PUT
update(id, data) {
        return ajax({
            url: `/test`,
            method: "PUT",
            body: JSON.stringify(data),
            crossDomain: true,
            withCredentials: true
        })
    }

Expected behavior
When exchanging "PUT" with "POST" a cookie is sent. PUT should behave the same way.

Environment

  • Runtime: Firefox 61.0.2
  • RxJS version: 6.2.2

Additional context/Screenshots
I'm not sure if I'm doing something incorrectly here, but when using "POST" everything works as expected. A cookie is sent and I can use my IP. But when using "PUT" I can see that the header does not include any cookie. Any help is appreciated!

@benlesh
Copy link
Member

benlesh commented Aug 21, 2020

Sorry I'm just getting around to seeing this. It seems like we're just lacking a feature to send a XSRF cookie via headers?

That seems like something worth adding, as it's non-trivial for people to reimpliment this over and over.

I'll leave this here for when someone gets around to implementing this feature... Here is how Axios does it, as an example seems like it would be straightforward for us to get in.

@benlesh benlesh added feature PRs and issues for features help wanted Issues we wouldn't mind assistance with. labels Aug 21, 2020
@DCtheTall
Copy link
Contributor

I'd like to take a crack at this, probably not over the long weekend but some time in the next week or so.

@DCtheTall
Copy link
Contributor

@benlesh I have a PR with the general implementation set up. I will get to unit testing it at some point in the next couple days. Let me know if this is what you had in mind 😄

benlesh pushed a commit that referenced this issue Sep 27, 2020
…er (#5702)

* feat(ajax.ts): send XSRF cookies in a custom header

* feat(ajax.ts): update API guardian

* feat(ajax.ts): review comments

* feat(ajax.ts): fix tests

* feat(ajax.ts): better isSameOrigin().

* feat(ajax.ts): use globalThis

* feat(ajax.ts): rm unused fn

* feat(ajax.ts): add tests and use config.crossDomain

* feat(ajax.ts): fix in Node 11

* feat(ajax.ts): rm globalThis

* feat(ajax.ts): fix globalThis in tests

* feat(ajax.ts): rm incorrect import

* feat(ajax.ts): update api_guardian

* feat(ajax.ts): delete readCookie

* feat(ajax.ts): update api_guard

* feat(ajax.ts): checkout master on unrelated files


closes #4003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs and issues for features help wanted Issues we wouldn't mind assistance with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants