I need to serve some image files from my app which are on a root folder called uploads
.
I am setting the middleware on the same level as my folder. The code currently looks like this:
const express = require('@feathersjs/express')
const Path = require('path')
app.use('/uploads', express.static(Path.join(__dirname, `uploads`)))
If I try to do fetch a using localhost:[MY_PORT_NUMBER]/uploads/myImage.jpg
I am currently getting a 404 and in the logs it is just getting the NotFound: Resource not found
message.
What am I doing wrong?
Try this:
app.use('/uploads', express.static(Path.join(__dirname, '/../uploads')));