Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to server static files? #467

Open
thunderwin opened this issue Jul 20, 2020 · 1 comment
Open

How to server static files? #467

thunderwin opened this issue Jul 20, 2020 · 1 comment

Comments

@thunderwin
Copy link

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

@DangelZM
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants