need help with hosting a simple website

hi, i am new to hosting projects, i just hosted a simple node + express application on netlify and i seem to be having issues. in my node server.js file i have this app.get("/course/:id", (req, res) => { but when i go to "mynetlifyurl/course/1" i get the netlify page not found error i tried askign gpt and bard for the solution but they aren't helpful
5 Replies
GSUS
GSUSOP•11mo ago
app.get("/course/:id", (req, res) => {
const courseName = req.params.id;
const course = courseData.find((course) => course.course == courseName);
if (!course) {
res.status(404).json("course not found");

res.render("course", { course });
});
app.get("/course/:id", (req, res) => {
const courseName = req.params.id;
const course = courseData.find((course) => course.course == courseName);
if (!course) {
res.status(404).json("course not found");

res.render("course", { course });
});
here is the complete endpoint
b1mind
b1mind•11mo ago
How to Deploy an Express.js Application to Vercel
Learn how to deploy an Express.js application to Vercel using Serverless Functions.
b1mind
b1mind•11mo ago
Basically it's a pita 🥲 Vercel and Netlify are "serverless“ hosting which means you need to wrap things in serverless functions to use them on their platform. Or find hosting for a nodejs server.
GSUS
GSUSOP•11mo ago
Yea that's what I ended up doing, using render instead of netlify
reddogg476
reddogg476•11mo ago
Hey GSUS, I'm not the node expert, but Netlify hosts static sites by default; your code is written to have a node server backend. You'll likely need Netlify Functions in addition to your repository to proceed: https://docs.netlify.com/functions/overview/ --> That way, the express api that's using app.get() can actively listen. --> Otherwise, you'd just add a html page in the project folder ./course/id to navigate.
Want results from more Discord servers?
Add your server