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

240
Views
Express wont find css file

I cant get my index.html in express to show the styles.

This is my folder structure:

folder structure

And then on server js I have this:

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

app.get('/', function(req, res){
  console.log('Listening on port ' + port)
  let isMobile = req.useragent.isMobile ? 'mobile' : 'desktop';
  console.log({isMobile})
  res.sendFile(path.resolve(__dirname + `/${isMobile}/index.html`));
});

And I just add the link tag on my html inside the head on the index.html like this:

  <link href="styles.css" rel="stylesheet" type="text/css">

The index I serve can be either inside the desktop or mobile folder But it doesnt get the styles... any idea whats the issue?

Thanks.

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

0

server.js

app.use(express.static(path.join(__dirname, 'server/public')

index.html

<link href="/styles.css" rel="stylesheet" type="text/css">
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!