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

IPX provider not working properly when the default provider is not IPX #1414

Open
mupinnn opened this issue Jul 23, 2024 · 6 comments · May be fixed by #1420
Open

IPX provider not working properly when the default provider is not IPX #1414

mupinnn opened this issue Jul 23, 2024 · 6 comments · May be fixed by #1420

Comments

@mupinnn
Copy link

mupinnn commented Jul 23, 2024

I have custom provider (thumbor) as my default provider in the config and in some case I still need IPX provider, so I pass provider props in the NuxtImg components as <NuxtImg provider="ipx" /> and the result is 404. _ipx path is not found.

The config I had:

image: {
  ipx: {},
  provider: "thumbor",
  providers: {
    thumbor: { ... }
  }
}

When I omit the ipx property, it throw Unknown provider: IPX error. The config works when I replace the default provider with ipx.

Is it expected behavior?

I create a minimal reproduction using ipx and unsplash provider to suit my problem: https://stackblitz.com/edit/nuxt-image-ipx-repro?file=app.vue

Thank you!

@Tofandel
Copy link

Tofandel commented Aug 5, 2024

I have a very similar issue, I'm trying to instantiate 2 ipx instances but only one is ever setup

With a bit of debug, that's because the providerSetup is made using the name of the provider instead the provider key of the provider

const setup = input.setup || providerSetup[input.name];

Your issue is part of this because there is some hardcoding to setup ipx

if (!options.provider || options.provider === "ipx" || options.provider === "ipxStatic") {
// Setup ipx

I'll solve it in the same PR

Tofandel added a commit to Tofandel/image-1 that referenced this issue Aug 5, 2024
@Tofandel Tofandel linked a pull request Aug 5, 2024 that will close this issue
6 tasks
@MickL
Copy link

MickL commented Sep 18, 2024

I also cant use ipx as a secondary provider. I use cloudflare as my main provider for images hosted on Cloudflare Images but I want to use ipx occasionally for static images:

Nuxt config:

image: {
    provider: 'cloudflare',
}

Component:

<NuxtImg src="/static-image.jpg" provider="ipx" />

Error:

[nuxt] [request error] [unhandled] [500] Unknown provider: ipx

Did you guys find a workaround?

@nathanchase
Copy link
Contributor

I found this out recently as well.

If I have this in my nuxt.config:

image: {
   provider: import.meta.env.NUXT_PUBLIC_IMAGE_PROVIDER,
}

it doesn't matter what I set that env var to - ipx will never run or work correctly in production.

If I do this instead:

image: {
   provider: import.meta.env.NUXT_PUBLIC_IMAGE_PROVIDER || 'ipx',
}

then that seems to signal to the production build that ipx is needed, and then it seems to actually install what's necessary to have ipx running on the built production server.

@MickL
Copy link

MickL commented Oct 8, 2024

Is there any news on this? @danielroe

@mrleblanc101
Copy link

Same issue for me, I want to default to prismic and use ipx as secondary

@Tofandel
Copy link

Tofandel commented Nov 18, 2024

If anyone wants to make a PR for this, feel free, just fixing this particular issue wouldn't take a huge change, as it's only necessary to change the condition for setting up IPX I mentionned, maybe just checking if ipx or ipxStatic key exists in the options or the list of providers, I do not have the time right now to work and finish my PR

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

Successfully merging a pull request may close this issue.

5 participants