rails/request.js

Ability to set the option 'credentials'

Cervenka opened this issue · 3 comments

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

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

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!

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