#ImageResponse crashes API route when cached
1 messages · Page 1 of 1 (latest)
Hmm, I don't know enough to give you a confident answer yet. However, based on the information provided, it seems like there might be an issue with how the ImageResponse is being cached and retrieved.
It's worth noting that in Next.js, the ImageResponse should be imported from next/server as mentioned in one of the extracts (https://github.com/vercel/next.js/issues/55604). If you're using a different import, it might be causing the issue.
Also, ensure that your GET route handler is correctly returning a Response or Promise<Response>. If it's returning undefined at any point, it could lead to the error you're seeing.
For more detailed help, I would recommend checking the Next.js documentation (https://nextjs.org/docs) or the Vercel guides (https://vercel.com/guides) for more information on how to handle responses in Next.js.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@abstract vault kapa.ai is still learning and improving, please let us know how it did by reacting below
@short halo ImageResponse should be imported from next/og since v14
Let me check the knowledge base for you. One moment! :books:
Yes, you're correct. Starting from Next.js version 14, the ImageResponse should be imported from next/og instead of next/server. This change was made as part of the updates in version 14 as mentioned in the Next.js documentation (https://nextjs.org/docs/app/building-your-application/upgrading/version-14#upgrading-from-13-to-14).
Here's how you can import ImageResponse:
import { ImageResponse } from 'next/og'