Skip to content
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

NuxtImage + IPX + SWR = return buffer #1400

Open
bernhardberger opened this issue Jul 5, 2024 · 7 comments
Open

NuxtImage + IPX + SWR = return buffer #1400

bernhardberger opened this issue Jul 5, 2024 · 7 comments

Comments

@bernhardberger
Copy link

bernhardberger commented Jul 5, 2024

When I enable SWR on our website IPX/nitro/whatever the culprit.. returns a buffer instead of an image:

image

Any ideas how to work around this? This has been a major issue for us, preventing is to run SWR on our website and customer projects..

@metkm
Copy link

metkm commented Jul 5, 2024

do you have reproduction? I can't seem to replicate the issue

@bernhardberger
Copy link
Author

bernhardberger commented Jul 5, 2024

Sure:
https://github.com/bernhardberger/nuxt-ipx-swr-buffer-minimal-reproduction

git clone https://github.com/bernhardberger/nuxt-ipx-swr-buffer-minimal-reproduction
cd nuxt-ipx-swr-buffer-minimal-reproduction
npm run build && node .output/server/index.mjs

-> hard reload (CTRL+SHIFT+R) a few times after 10 seconds -> image will be dead

@bernhardberger
Copy link
Author

related: nuxt/nuxt#27307

@bernhardberger
Copy link
Author

Imho this should be documented..

@bernhardberger
Copy link
Author

bernhardberger commented Jul 18, 2024

We have now solved this using a nitro onBeforeResponse hook that unwraps and streams the Buffer so we can still use swr caching on /_ipx/** generated images (so the image gets served from a cache and the user won't have to wait for the regenerated image every time)

We'll provide a code sample later when it's tested.

@manot40
Copy link

manot40 commented Nov 3, 2024

Hey @bernhardberger, did you already done working with nitro hook code sample? Thanks in advance.

@Nagell
Copy link

Nagell commented Nov 9, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants