Basic Node and Express - Serve Static Assets

Tell us what’s happening:

I have implemented as everyone did, but the challenge did not pass. Please help!

app.get("/", function (req, res) {
  const absolutePath = __dirname + "/views/index.html";
  res.sendFile(absolutePath);
});

app.use(express.static(__dirname + "/public"));

###Your project link(s)

solution: https://69c5bbc8-d777-443d-8a5d-7adca2cb0f29-00-32gdgzb09iqny.kirk.replit.dev

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Basic Node and Express - Serve Static Assets

You need the mount path.

A middleware needs to be mounted using the method app.use(path, middlewareFunction) .

Mount the express.static() middleware to the path /public with app.use() .

Look at the docs for examples of how to use it.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.