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

Allow customization of Axios instance #627

Closed
gingerich opened this issue Jun 9, 2022 · 2 comments
Closed

Allow customization of Axios instance #627

gingerich opened this issue Jun 9, 2022 · 2 comments

Comments

@gingerich
Copy link

Problem

I'm using this SDK in a project running on Cloudflare Workers which is not a native Node runtime. Axios expects either XMLHttpRequest or Node's http module to be available which causes an error since Cloudflare Workers only supports the standard Fetch API.

Proposal

Axios accepts custom adapters to provide the underlying http client implementation. The adapter is specified within Request Config. I would like to customize the Axios client instance by passing in additional options to the WorkOS constructor. This could be done by passing in a Axios instance or the Request Config used to create the Axios instance. This would also be useful to create mock implementation for testing.

For example,

new WorkOS(key, {
  axios: axios.create({ adapter: myFetchAdapter })
});
@maxdeviant
Copy link
Contributor

Hey @gingerich, as of v2.12.0 we now support customizing the underlying Axios instance using the axios option:

new WorkOS(key, {
  axios: { adapter: myFetchAdapter },
});

@gingerich
Copy link
Author

@maxdeviant Excellent, thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants