Description
buildOfetchOptions (in client-ofetch/bundle/utils.ts) builds the object passed to $ofetch.raw() from a fixed allowlist — it names each option and drops the rest (no ...opts spread). RequestOptions and the plugin config (only throwOnError) offer no escape hatch either.
So there's no supported way to forward an option the template doesn't list:
- Standard
RequestInit fields ofetch supports (keepalive, mode, integrity, priority, …) get silently dropped.
- Custom options for a swapped-in fetch (e.g.
onUploadProgress for an XHR-based fetch) can't reach it at all.
The only workaround today is string-patching the generated utils.gen.ts / types.gen.ts, which is brittle.
Possible fixes (any one works):
- Spread standard
RequestInit fields in buildOfetchOptions.
- Plugin config allowlist, e.g.
forwardOptions: ['keepalive', 'onUploadProgress'].
- A
fetchOptions passthrough on RequestOptions, merged verbatim into the $ofetch.raw() call.
Env: @hey-api/openapi-ts 0.99.0, @hey-api/client-ofetch, ofetch 2.x
Description
buildOfetchOptions(inclient-ofetch/bundle/utils.ts) builds the object passed to$ofetch.raw()from a fixed allowlist — it names each option and drops the rest (no...optsspread).RequestOptionsand the plugin config (onlythrowOnError) offer no escape hatch either.So there's no supported way to forward an option the template doesn't list:
RequestInitfields ofetch supports (keepalive,mode,integrity,priority, …) get silently dropped.onUploadProgressfor an XHR-based fetch) can't reach it at all.The only workaround today is string-patching the generated
utils.gen.ts/types.gen.ts, which is brittle.Possible fixes (any one works):
RequestInitfields inbuildOfetchOptions.forwardOptions: ['keepalive', 'onUploadProgress'].fetchOptionspassthrough onRequestOptions, merged verbatim into the$ofetch.raw()call.Env:
@hey-api/openapi-ts0.99.0,@hey-api/client-ofetch,ofetch2.x