-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
Custom fetch options are stripped from the request. Next.js cache doesn't work properly. #1569
Comments
Ah, hm. I was somewhat afraid this would happen, and did see it come up in one other test failure, but had thought it was fixed. Would gladly welcome any PRs for this! This should be a fairly-straightforward issue to write a failing test for, and find a fix. |
PR created. |
For the workaround, this could be ok as well as the cache mechanism, regardless a little wired. const res = await client.GET("/api/v1/space", {
fetch: (request: unknown) => {
return fetch(request as Request, { next: { revalidate: 40 } } )
}
}) I have tested it in Next.js 14 |
Hi, a pull request fixing this was merged #1653 recently |
Hi, i'm still facing this issue on some Next.js 14 routes after using the latest I'm just looking for clues here and I assume the problem is linked to this issue, whereby something Next-related isn't being or can't be passed through. Any help or guidance of what to investigate further would be much appreciated. In the interim, is there a way to apply the custom fetch argument in a DRY manner, similar to how we can apply middleware? In the event that i have to add this to all my mutations |
My $0.02 having been bit by and consequently moved away from Next.js. This is a problem with Next.js' API design rather than openapi-ts. Overloading and modifying the native |
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed. |
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem. |
Description
Openapi-fetch uses a request object for its fetch. https://github.com/drwpow/openapi-typescript/blob/9c277fb0a10c3513de46765a4381ccb722a72af4/packages/openapi-fetch/src/index.js#L101
The request object created by openapi-fetch strips away non standard fetch options, i.e. how Next.js passes its cache related params:
More info on Next.js fetching data + caching
Reproduction
Try to pass next cache params in https://github.com/drwpow/openapi-typescript/blob/main/packages/openapi-fetch/examples/nextjs/app/page.tsx
It won't change its behaviour, it always falls back to defaults, because the non standard ones are stripped away.
I've tried
I changed this line
https://github.com/drwpow/openapi-typescript/blob/9c277fb0a10c3513de46765a4381ccb722a72af4/packages/openapi-fetch/src/index.js#L101
to
and it works, but I don't know if it would cause other problems.
The text was updated successfully, but these errors were encountered: