Replies: 1 comment 1 reply
-
|
This is probably no longer relevant but have you tried |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm wondering if there's any way to access files in the
publicdirectory directly through server-side JavaScript? That is, usingfsinstead of, say, in the HTML through<img src="/something.png">. My use case is that there's a list of images I want to show, but in case an image doesn't exist in the directory (which I was trying to find out throughfs.readdir(...).includes(...)), I want to replace the image's URL with a fallback URL, and I'd like for all this to happen server-side instead of waiting for the image to fail to load in the browser.Another use case is that I want to keep some data that my site uses in publicly-available JSON files. I know you can just
importJSON file if it's located inside theappfolder like the rest of the source code, but I'd like to keep this data separate from the site's source and also accessible to anyone by entering its URL.I've tried straight up accessing
fs.readdir("public/....."), and that works when running locally, but threw anENOENT: no such file or directoryerror when I tried to deploy it to Netlify.Beta Was this translation helpful? Give feedback.
All reactions