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

Relative <img> 404s when using next/link and trailingSlash in Safari #65009

Open
blakewilson opened this issue Apr 24, 2024 · 8 comments
Open
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@blakewilson
Copy link

blakewilson commented Apr 24, 2024

Link to the code that reproduces this issue

https://github.com/blakewilson/relative-img-path-bug

To Reproduce

  1. Start the application in dev mode
  2. Go to http://localhost:3000
  3. Click the first link and confirm that the image exists on the /hello-world route
  4. Go back to http://localhost:3000
  5. Click the second link (using next/link) and notice the image 404s on the /hello-world route. Refresh the page, and notice the image appears.

Current vs. Expected behavior

Following the steps above, I expect to see the correct image when rendering the hello world route via next/link. Instead, the image 404s.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:51 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 18.17.0
  npm: 10.2.5
  Yarn: N/A
  pnpm: 8.15.1
Relevant Packages:
  next: 14.3.0-canary.21 // Latest available version is detected (14.3.0-canary.21).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Not sure

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

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

NEXT-3245

@blakewilson blakewilson added the bug Issue was opened via the bug report template. label Apr 24, 2024
@blakewilson
Copy link
Author

Upon inspecting the network log, you can see a request is being made for https://localhost:3000/lunch.jpeg, instead of https://localhost:3000/hello-world/lunch.jpeg

Screenshot 2024-04-24 at 6 15 56 PM

@blakewilson
Copy link
Author

blakewilson commented Apr 25, 2024

This appears to only happen in Safari (Current version is 17.2.1). Chromium it works.

Here is a demo (Chrome on the left, Safari on the right):

Next.js.bug.mov

@samcx samcx added the linear: next Confirmed issue that is tracked by the Next.js team. label Apr 27, 2024
@samcx samcx changed the title Relative <img> 404s when using next/link and trailingSlash Relative <img> 404s when using next/link and trailingSlash in Safari Apr 27, 2024
@samcx
Copy link
Member

samcx commented Apr 27, 2024

@blakewilson Thanks for sharing! I was able to replicate the issue. We will take a look at this!

@blakewilson
Copy link
Author

@samcx Awesome! Thanks. Let me know if I can help, happy to make a PR.

@deeseeker
Copy link

deeseeker commented Sep 18, 2024

@samcx could you please grant @blakewilson the request to make a PR for this issue?

If the issue has been fixed, I suggest we close it to free up the open issues stats.

@samcx
Copy link
Member

samcx commented Sep 18, 2024

@blakewilson @deeseeker I apologize—this has fallen through the cracks!

If you are able to create a PR, I will be happy to take a look and review.

@deeseeker
Copy link

@blakewilson @deeseeker I apologize—this has fallen through the cracks!

If you are able to create a PR, I will be happy to take a look and review.

Hi @samcx,

Thank you for opening this issue up for contribution! I usually try to support maintainers by prompting them about pending issues, but since you've made this available, I may take a look at it during my free time.

@samcx
Copy link
Member

samcx commented Sep 20, 2024

@deeseeker You don't have to ask for permission in the future, but I guess it's good to ask so work isn't duplicated.

That will be great if you want to take a look!

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. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

No branches or pull requests

3 participants