Serving static assets #686
-
Hi, I would like to have an example about serving static folders in Payload. Theses files can be used for instance in I tried using express.static in my
Is there any example/documentation about serving static files in Payload that I can take a look at ? Thanks a lots ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is really an express question more than to do with Payload. When you say you get a 404 from Assuming that you are requesting files it has to be a problem with how you are calling express.static. We use What happens if you try |
Beta Was this translation helpful? Give feedback.
This is really an express question more than to do with Payload.
When you say you get a 404 from
localhost:3000/public
are you specifying the file too as inlocalhost:3000/public/favicon.ico
? The expected result for hitting just the directory path is a 404 unless you have a handler set also.Assuming that you are requesting files it has to be a problem with how you are calling express.static. We use
path.resolve(__dirname, './assets/public')
rather than+
to concat path names together.What happens if you try
app.use('/public', express.static(path.resolve(__dirname, './assets/public'));
?