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

Images in /public not served on Vercel #18

Closed
bennash opened this issue Dec 1, 2024 · 4 comments · Fixed by #60
Closed

Images in /public not served on Vercel #18

bennash opened this issue Dec 1, 2024 · 4 comments · Fixed by #60

Comments

@bennash
Copy link

bennash commented Dec 1, 2024

I'm not getting vercel to show the images in the /public directory. Is there some config to set? thanks

@corwinm
Copy link

corwinm commented Dec 31, 2024

@bennash I was able to update my vercel/output/config.json and get images to load. I'm not sure if this is the best way to do this or if there is a downside but it got me past this issue.

{
  "version": 3,
  "routes": [
    {
      "src": "/favicon.ico",
      "dest": "/favicon.ico"
    },
    {
-      "src": "/assets/(.*)",
-      "dest": "/assets/$1"
+      "src": "/(.*)",
+      "dest": "/$1"
    },
    {
      "src": "/(.*)",
      "dest": "/"
    }
  ]
}

trogers1 added a commit to trogers1/taylorrogers.com that referenced this issue Jan 7, 2025
@brookslybrand
Copy link
Contributor

Thanks @corwinm for the suggestion. I just merged in #60 which is based off your input. Key differences:

  • Kept the /assets/ routing and added default caching to it (like in node-custom-server)
  • Updated the route config below to be the catchall you provided

Also, @bennash, I generally recommend importing images directly (see the <Welcome /> component), since Vite will bundle them up and fingerprint them for you. But you do whatever works best for you

Thanks for opening the issue!

@brookslybrand
Copy link
Contributor

Actually @corwinm I had to revert this in #62

I would recommend adding something like this to vercel/output/config.json:

  {
    "src": "/pics/(.*)",
    "dest": "/pics/$1"
  },

Basically you just need to let Vercel know requests you dont' want to be handled by React Router directly

@corwinm
Copy link

corwinm commented Jan 18, 2025

Thanks @brookslybrand! I'll have to update my config later and see how it goes. I like the idea of having the public folder "just work" but I can also understand the need to have restrictions here and more control over cache. I think my use case was centered around a site.manifest and the icons there. Thats easy enough to configure to work but in an ideal world anything in the public directory would be public.
Not sure if this is a common enough use case to warrant a section in the README but I wouldn't say it is straight forward.
Also a bit unfortunate that you wouldn't run into this locally and it would only be after it is deployed, but we all are deploying to branches and testing before we push to prod right? ...Right?

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

Successfully merging a pull request may close this issue.

3 participants