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

202
Views
Express throws path must be absolute or specify root to res.sendFile when I use react router's redirect in react app bild

I serve a react-app built version in express, when I login it should redirect and show me another page. However, when I redirect to the right url I got this error path must be absolute or specify root to res.sendFile How can I solve it? Why can't I see other pages other than root? Here is the code in express:

const app = express();
const portApp = 3003;

app.use(cors());
app.use(bodyParser.json());
app.use(
  bodyParser.urlencoded({
    extended: false,
  })
);

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

app.get("/attendances", (req, res, next) => {
  res.sendFile(path.join(__dirname, "build", "index.html"));
});

app.use((req, res, next) => {
  res.sendFile(path.join(__dirname, "build", "index.html"));
});

app.listen(portApp, () => {
  console.log(
    `Attendance list App is listening at http://localhost:${portApp}`
  );
});
about 4 years ago · Juan Pablo Isaza
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!