Basic Node and Express - Serve Static Assets

hi, I have tried all the methods explained and took help with the hint but nothing seems to work for me,
CODE:

app.get(“/”, (req, res) => {
absolutePath = __dirname + ‘/views/index.html’;
res.sendFile(absolutePath);
});

app.use(express.static( ‘/public’));
// I tried it this way too…
app.use(‘/public’, express.static( __dirname + “/public”));

Below is the error I am getting:
// running tests Your app should serve asset files from the

/public
```directory to the

/public

path // tests completed // console output [Error: Not Found]



**Your project link(s)**


solution: https://boilerplate-express--luma-naima.repl.co

**Your browser information:**

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

**Challenge:** Basic Node and Express - Serve Static Assets

**Link to the challenge:**
https://www.freecodecamp.org/learn/back-end-development-and-apis/basic-node-and-express/serve-static-assets

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