Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Express Send Files in Folder

I have a server with files like this:

- index.js
/client
 -index.html
 -about.html
 -signup.html
 -style.css

In index.js I have a express server.

  • When the user goes to / , it should go to index.html
  • When the user goes to /about.html it should go to about.html etc
  • When the user goes to /style.css it should go to style.css etc..

I know you can do it like this..

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/client/index.html')
})

But I want to make it so that it automatically sends the correct file without having to get each folder.

I know it has something to do with app.use but I am not fully sure how to use it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Whoops, I never thought it would be this easy-

app.use('/', express.static('client'))

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!