Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.
413 stars 51 forks source link

Enable setting of custom headers in remoteOptimizedImages.js #223

Open Niels-IO opened 3 weeks ago

mmarseu commented 3 weeks ago

Thank you for this. It seems to work as advertised. Unfortunately it turns out this is only a partial solution to my problem. I wasn't aware of this until I tested your solution but apparently the server also blocks HTTP/1.1 connections. When I request the same image using the same headers with HTTP/2, it works.

I'm not sure that you consider this within scope of your package. If you do, I'll write another issue for this.

As a workaround, would it also be possible that I fetch the images manually in another script and provide them to your package for processing?

Niels-IO commented 2 weeks ago

Hi @mmarseu, I am hesitant to switch to Node.js http2 library. I fear that, in turn, not all servers would accept a http2 request.

mmarseu commented 2 weeks ago

I'm sure that's true and since I'm hardly an expert on network protocols, I can't provide any suggestions.

So given that in any case I have to provide image URLs in remoteOptimizedImages.js, I might as well fetch them myself, using any technology at my disposal and provide them to your tool for processing. This would be a convenient workaround for me and all similar cases, I'd say. Is that already supported?