Nitro server plugin to cache Nuxt images: how to respond with a file from disk?
Hi, I am writing a server plugin like below. I am using the @nuxt/image module with the ipx provider. I would like it to save its generated image files to disk, and serve those files whenever the exact same file is requested.
This example below works. I get served files from disk. But I am using a
new Response
and doing event.respondWith(res);
which keeps resulting in this error in the CLI:
My knowledge of Nitro is limited; if I were to create a plugin like this, is this the correct way? How can I respond with the image file inside the request
hook without getting [500] Cannot set headers after they are sent to the client
? Should I use another method to create this functionality? Help is greatly appreciated π
1 Reply
Complete error:
Should I be ending the original response somehow? Should I not use
event.respondWith()
?