express-mongoose-es6-rest-api icon indicating copy to clipboard operation
express-mongoose-es6-rest-api copied to clipboard

How to server static files?

Open thunderwin opened this issue 5 years ago • 1 comments

app.use("/static", express.static(path.join(__dirname, "public")));

How to server static files?

I did some wrong?

I put it on config/express.js

thunderwin avatar Jul 20 '20 06:07 thunderwin

@thunderwin can you share where 'public' folder located in your project structure? app.use('/static', express.static(path.join(__dirname, 'public'))) try to find 'public' in config/public if your 'public' folder located in root folder of your project use app.use('/static', express.static(path.join(__dirname, '/../public')));

__dirname - The directory name of the current module, so it path to directory where located file you add __dirname The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

DangelZM avatar Jul 20 '20 14:07 DangelZM