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

Unable to read static Image files in /public using IPX as provider on vercel, seeing [404] [IPX_FILE_NOT_FOUND] error #1281

Open
cfdxkk opened this issue Mar 8, 2024 · 7 comments

Comments

@cfdxkk
Copy link

cfdxkk commented Mar 8, 2024

1. Issue

Unable to read static Image files in /public using ipx as provider on vercel, seeing [404] [IPX_FILE_NOT_FOUND] error.

{
    "error": {
        "message": "[404] [IPX_FILE_NOT_FOUND] File not found: /nuxtImage.png"
    }
}

This works in both local dev and production (Vercel) environment.

<img style="width: 300px" src="public/nuxtImage.png" />

This only works in local dev environment and get [404] [IPX_FILE_NOT_FOUND] error in production (Vercel) environment.

<NuxtImg width="300" src="nuxtImage.png" />

This works in both local dev and production (Vercel) environment.

<NuxtImg width="300" src="https://i2.100024.xyz/2024/03/08/irvlgw.webp" />

image

2. Using

  "dependencies": {
    "@nuxt/image": "^1.4.0",
    "nuxt": "^3.10.3",
    "vue": "^3.4.19",
    "vue-router": "^4.3.0"
  }

3. Minimal Reproduction

Source Code: https://github.com/cfdxkk/nuxt-image-vercel-ipx
Online Demo: https://nuxt-image-vercel-ipx.vercel.app/

4. Something Maybe Useful

nuxt.config.ts

export default defineNuxtConfig({
	devtools: { enabled: false },
	modules: [
		'@nuxt/image',
	],
	image: {
		provider: 'ipx',
		domains: ['i2.100024.xyz'],
		dir: 'public/'
	}
})

Vercel build command (nuxt default)

image

Source & Build Output in Vercel

Source
image

Build Output
image

@Jdu278
Copy link

Jdu278 commented Mar 10, 2024

Having similar issues but receiving Error: [403] IPX_FORBIDDEN_PATH when running nuxi generate.

@cfdxkk
Copy link
Author

cfdxkk commented Mar 12, 2024

Other developers report same issue here #1006

@Aira-Sakuranomiya
Copy link

Same when deployed on Zeabur.

@KnoerleMan
Copy link

Any new insights on this issue?
I am having the same issue on netlify.

Using nuxt generate instead of nuxt build "fixes" the problem.
Anyway this does not seem like a solution.

@haidertm
Copy link

Have anyone found any solution to this?
Facing similar issue, images already in public/images directory.

but not sure why vercel looking for images in static directory?

@cfdxkk
Copy link
Author

cfdxkk commented May 15, 2024

@haidertm

Have anyone found any solution to this? Facing similar issue, images already in public/images directory.

but not sure why vercel looking for images in static directory?

I gaved up, it still bug but try another inelegant way to fix.
now i use a mixing mode:


If I am sure that image must is a internet image, I will use a Custom Provider like this.
Specifically, it splices a URL and requests a resized image, so that the image processing task will be completed by a third-party provider.

<NuxtImg provider="yourProvider" src="https://cloudflare.com/foo.jpg" />

If i am sure a image use static file. I will NOT set the provider attribute.
No provider means automatic provider. So the provider will be ipx in my localhost environmentand Vercel Image Optimization in Vercel production environment.

<NuxtImg src="static/bar.jpg" />

If i don't know a image is internet or static, I will use v-if / v-else and a Computed Properties.

<script lang="ts">
  const imageUrl = ref<string>('static/baz.jpg') // This URL maybe change into a Internet image.
  const isStaticImage = computed(() => imageUrl.value.startsWith('static/'))
</script>

<template>
  <NuxtImg v-if="isStaticImage" :src="imageUrl" />
  <NuxtImg v-else provider="yourProvider" :src="imageUrl" />
</template>

@JasonLandbridge
Copy link

Just my 2 cents, make sure the images aren't inside ClientOnly tags, as the NuxtImg is server-side only because it crawls the image references server side and based on that, it bundles the images during nuxt generate.

Removing ClientOnly tags fixed this same issue for me as I wrongly assumed NuxtImg can be used client side

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

6 participants