rails / request.js

MIT License
389 stars 28 forks source link

Ability to set the option 'credentials' #55

Closed Cervenka closed 1 year ago

Cervenka commented 1 year ago

It may be useful to be able to set the option credentials to include.

At the moment it is hardcoded to same-origin. https://github.com/rails/request.js/blob/main/src/fetch_request.js#L59

https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters

Thank you

marcelolx commented 1 year ago

Hey @Cervenka, do you have a use case in which you need to set it to include? I agree that it can be useful, but would like to know the use case before we move forward

Cervenka commented 1 year ago

In my case I'm sending requests to a different subdomain (app.domain.com --> legacy-api.domain.com) - so cross origin. legacy-api.domain.com's responds with the correct CORS headers.

I need the request to include the cookies that are shared across *.domain.com. With the option set to same-origin the cookies are not included - similar to XHR calls with withCredentials set to false.

Thanks!

marcelolx commented 1 year ago

gotcha, thanks, I may have some time tomorrow to work on it.