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

Disabling file-system routing affects serving files from the public directory #9962

Closed
ussuritiger opened this issue Jan 6, 2020 · 2 comments · Fixed by #10169
Closed

Disabling file-system routing affects serving files from the public directory #9962

ussuritiger opened this issue Jan 6, 2020 · 2 comments · Fixed by #10169
Labels
good first issue Easy to fix issues, good for newcomers
Milestone

Comments

@ussuritiger
Copy link

Bug report

Describe the bug

According to the documentation setting the useFileSystemPublicRoutes configuration option to false prevents routing based on files in /pages directory. If this option is set to false in combination with using a custom server, images (and most likely other file types) are not served from the /public directory. The 404 page is served instead.

To Reproduce

  1. Use an example with custom server (tested with Fastify)
  2. Create /public directory with an image inside
  3. Add HTML image tag with the /image-name as src attribute to any page
  4. Add next.config.js file to the root with the following content:
module.exports = {
  useFileSystemPublicRoutes: false
}
  1. Open modified page in the browser

Expected behavior

Image is shown regardless of useFileSystemPublicRoutes configuration option's value.

@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers help wanted labels Jan 6, 2020
@AaronDDM
Copy link

AaronDDM commented Jan 7, 2020

I am able to replicate this - it's because of:
https://github.com/zeit/next.js/blob/canary/packages/next/next-server/server/next-server.ts#L560

Essentially the "catch all" is only included if useFileSystemPublicRoutes is set to true - however DevServer relies on "catch all" to serve files from the public folder.

Because we do not rely on the catch all method for production - this issue doesn't occur in production for serving files from the public folder.

Q: Anyone see any issue with moving routes.push(catchAllRoute); outside of the useFileSystemPublicRoutes check?

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
5 participants