unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.54k stars 61 forks source link

IPX `fetchOptions` and `async` token #76

Closed ThornWalli closed 1 year ago

ThornWalli commented 2 years ago

Hello,

I'm writing again because of the fetchOptions option.

I run into the problem that I need to asynchronously retrieve an auth token, and using nuxt/image and a custom ipx middleware I have no way to generate an actual token on demand or update it.

Meaning in the current state, I can create a token once, and at some point restart the instance.

An alternative would be a proxy middleware, but in this case I run into the fixed IPX options to the alias. The problem here is the random port of Nuxt generate, I would need this in the alias. Finally the IPX can address the proxy to solve the auth problem.

@pi0 Do you have an idea?

pi0 commented 1 year ago

Hi @ThornWalli. I think this is a valid thing to support. However even if ipx supports an async option, we cannot serialize it for nuxt image module.

I have created followup tracker in image: https://github.com/nuxt/image/issues/792