Skip to content

[Bug]: Images in public files don't load while in preview mode #753

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

Closed
2 tasks
Christopotamus opened this issue Oct 29, 2021 · 3 comments · Fixed by #761 or #918
Closed
2 tasks

[Bug]: Images in public files don't load while in preview mode #753

Christopotamus opened this issue Oct 29, 2021 · 3 comments · Fixed by #761 or #918
Labels
type: bug code to address defects in shipped code

Comments

@Christopotamus
Copy link

Christopotamus commented Oct 29, 2021

Steps to reproduce

I've created a project with create-next-app that simply includes an image on the page as well as the /api/ preview files taken from the demo project of this repo.

To see what's happening:

  1. https://naughty-borg-b1bb33.netlify.app to see the index page which includes an img tag that loads an image from the public directory
  2. https://naughty-borg-b1bb33.netlify.app/api/enterPreview to enter preview mode
  3. Go back here https://naughty-borg-b1bb33.netlify.app to see that the image no longer loads

I'm not quite sure why this is happening yet, but maybe the route handling for preview mode isn't handling images in the public folder?

This only seems to affect preview mode as far as I can tell. I've tested in another repository and it seems to affect any file located in the public directory.

A link to a reproduction repository

https://github.com/Christopotamus/next-netlify-preview-images

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

No response

Your netlify.toml file

No response

Relevant log output (or link to your logs)

No response

@Christopotamus Christopotamus added the type: bug code to address defects in shipped code label Oct 29, 2021
@ascorbic
Copy link
Contributor

ascorbic commented Nov 2, 2021

Thanks for the report. I've isolated this, and it's related to the redirects we add for preview mode to ensure it uses SSR. It's overriding the static files. We need to be more specific with the redirects to avoid this.

@Christopotamus
Copy link
Author

Christopotamus commented Dec 6, 2021

Sorry to resurrect this, but this looks like this is broken again with the latest release (rc.0)

I've updated my repo above with the latest 4.0.0.rc.0 release and following the same steps as before shows the same behavior

I looked through https://github.com/netlify/netlify-plugin-nextjs/blob/release-v4.0.0/src/helpers/redirects.ts which looks like where the issue would be, but don't know the codebase well enough to help out with a pull request yet

@ascorbic
Copy link
Contributor

ascorbic commented Dec 7, 2021

Thanks for the report, @Christopotamus. I'll look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
2 participants