-
Notifications
You must be signed in to change notification settings - Fork 15
Unable to set credentials property of fetch configuration #185
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
Comments
@tatethurston just updating the issue to say that I realized I can workaround this for now by doing the following:
Not sure what your thoughts are here, but this feels suboptimal to me insofar as I think it'd be great to extend |
Hey @andrewbeckman 👋 using Another workaround is using middleware: client.use((context, next) => {
return next({ ...context, credentials: "include" } as any);
}); But I think the intent is less clear here than with the Ideally I think we'd want something like: client.credentials = "include" or client.options = { credentials: "include" } |
The next piece is thinking about typing this -- we should be able to lean on TypeScript to prevent silly errors like: // credential should be credentials
client.options = { credential: "include" } I'm hesitant to force coupling to the full fetch interface, because that makes Making ClientConfiguration<RpcOptions = RequestInit> Though the mutable import { client } from 'twirpscript';
const myClient = client as ClientConfiguration<CustomOptions> or import { client, type ClientConfiguration } from 'twirpscript';
(client as ClientConfiguration<CustomOptions>).options = { ... }; That may be an acceptable for now for custom |
@tatethurston thanks for the detailed writeup! The motivation behind not being wed to fetch makes sense & I appreciate the complexity here. The idea of making |
Thanks @andrewbeckman. I'm going to research this a bit more. I may need to wait until bringing |
I would like to set the credentials property for the underlying
fetch
requests made by TwirpScript clients.More generally, I think it might be a nicer design to expose the optional ability to set any of the
fetch
config. But I'm only blocked by thecredentials
right now as I'm implementing cookie based authentication.The text was updated successfully, but these errors were encountered: