I'm doing a simple node project to practice but i can't manage to serve html file with its css styles. I asked the same question before on SO but I didn't mention that the status of css file was "canceled" in the developer tools. When I edited it nobody answered about why it is canceled, so i wish someone help me with this. It is making me crazy. Here is my app.js code: app.use("/signup", express.static("public"));
app.get("/", (req, res)=>{
res.send("Welcome to our website");
});
app.get("/signup", (req, res)=>{
res.sendFile(`${__dirname}/index.html`)
})
Here is my html code:
<head>
<title>testapp</title>
<link href="./public/styles.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<form method="post" action="/signup">
<input type="text" placeholder="*First Name" required></input>
<input type="text" placeholder="*Last Name" required></input>
<input type="number" placeholder="*Age" required></input>
<input type="email" placeholder="*Email" required></input>
<input type="submit" value="Submit" required></input>
</form>
</body>
When I remove the get method of "/signup", and put my index.html in the public directory while updating the link to css, it works just fine, but i don't want it in the '/' route. And also when opening the index.html file without the localhost, it works fine. I searched about it and found someone who had kind of the same issue asked about on SO, I think that the answers aren't right in my case, i'm not sure and i didn't understand well.What does status=canceled for a resource mean in Chrome Developer Tools?.
Thank you in advance.