Rxjs: Ajax with PUT and CORS

Created on 10 Aug 2018  路  3Comments  路  Source: ReactiveX/rxjs

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!

Help Wanted feature

Most helpful comment

@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 馃槃

All 3 comments

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.

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

@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 馃槃

Was this page helpful?
0 / 5 - 0 ratings