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

NextNodeServer handleNextImageRequest doens't work as expected with assetPrefix and custom next/image loader #65980

Open
mantaspatsSurfShark opened this issue May 20, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@mantaspatsSurfShark
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/friendly-montalcini-mc6sg6

To Reproduce

  1. Start the application in development (next dev)
  2. Home page doesn't show image (image returns 404)
  3. Disabling i18n in config will display image (can be seen here https://codesandbox.io/p/devbox/frosty-fast-wg5kmc)

Current vs. Expected behavior

Image should be shown correctly.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.3.0-canary.70 // Latest available version is detected (14.3.0-canary.70).
  eslint-config-next: N/A
  react: 19.0.0-beta-04b058868c-20240508
  react-dom: 19.0.0-beta-04b058868c-20240508
  typescript: 5.1.3
Next.js Config:
  output: N/A
Done in 2.08s.

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

#52492 This pull request not just separated routing code from render servers, but changed how next/image requests are recognized. Before, using regex matched if there is /_next/image in path. But now parsedUrl.pathname needs explicitly to start with /_next/image. But when i18n is enabled in next config, now parsedUrl.pathname starts with /{locale}/{assetPrefix}/_next/image and fails parsedUrl.pathname.startsWith('/_next/image')

@mantaspatsSurfShark mantaspatsSurfShark added the bug Issue was opened via the bug report template. label May 20, 2024
@github-actions github-actions bot added the Image (next/image) Related to Next.js Image Optimization. label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

No branches or pull requests

1 participant