Reputation: 241
How do would I serve static files from my base directory? Would it just be a /
or would I have to include the name of the base directory, which in this case would be Scanning
app.use(express.static(join(__dirname, '/')));
Upvotes: 0
Views: 36
Reputation: 707326
You need to use or construct the actual full path to the base directory. You don't show your actual directory structure and where the desired directory is relative to the directory that your code is running from.
If you wanted express.static()
to serve from the Scanning
directory which is a sub-directory of the directory you code is located in, you would do this:
app.use(express.static(path.join(__dirname, 'Scanning')));
Or, if Scanning
is a sibling of __dirname
, then it would be this:
app.use(express.static(path.join(__dirname, '../Scanning')));
You should never be serving files with express.static()
directly from __dirname
because that would allow your server to serve up your actual source files (and sometimes things like credentials).
Upvotes: 1
Reputation: 1226
Pretty close, just a few adjustments!
app.use(express.static(`${__dirname}/Scanning`))
Upvotes: 1