Replies: 1 comment
-
|
Let's move this to issues #3444 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When using
@hey-api/client-fetchwithruntimeConfigPath, the exportedcreateClientConfigfunction is synchronous:This works well for simple cases like setting a static
baseUrl. However, in server-side multi-tenant applications (e.g. a Next.js app serving multiple brands), the client configuration depends on per-request data that requires async operations:await headers()in Next.js App Router)Current workaround
Since
createClientConfigcan't be async, theruntimeConfigPathfeature is unusable for this scenario. Instead, we create a fresh client per request in a manual wrapper:Then every SDK call needs the client passed explicitly:
This works, but it means:
clientexported fromclient.gen.tsis never usedruntimeConfigPathfeature provides no value{ client }Proposal
It would be great if
createClientConfigcould optionally be async:Alternatively, a different mechanism that supports per-request configuration in server-side contexts would work too — for example, a
clientProviderpattern or middleware-style hook that runs before each request.Use case summary
await headers()in Next.js)Related
createClientConfigblocking server-side per-request configuration.Thanks for the great library! Happy to discuss alternative approaches.
Beta Was this translation helpful? Give feedback.
All reactions