-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adjust client options to send credentials when needed #790
Adjust client options to send credentials when needed #790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Cole! Thanks for contributing this! Overall looks great! Could you please adjust default values and also fix linter and tests.
@@ -2,10 +2,11 @@ import fetch from 'cross-fetch'; | |||
import 'url-search-params-polyfill'; | |||
|
|||
class HttpTransport { | |||
constructor({ authorization, apiUrl, headers = {} }) { | |||
constructor({ authorization, apiUrl, headers = {}, credentials = 'same-origin' }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave default value to fetch
itself and just remove 'same-origin'
.
@@ -25,10 +25,12 @@ class CubejsApi { | |||
this.apiToken = apiToken; | |||
this.apiUrl = options.apiUrl || API_URL; | |||
this.headers = options.headers || {}; | |||
this.credentials = options.credentials || 'same-origin'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@colefichter Looks great! The only thing in index.d.ts |
Check List
Note: the build instructions in the contribution guide are not working for me, so I can't build/run/test this change myself. Sorry about that!
Issue Reference this PR resolves
Original request here: #788
Description of Changes Made (if issue reference is not provided)
The Fetch API supports a credentials option to control the session cookies sent along with a request. By adjusting the Cube.js Client to support this option, we will be able to route our cube queries through a different sub-domain.
For example. If your site is running at secure.mydomain.com and your API calls need to go to api.mydomain.com it can be handy to pass the cookies over in the cross-domain API call. In order to support such a request pattern, the cube client must allow us to set credentials: 'include' when calling fetch().