ARTICLE AD BOX
I want to host a Node.js app using Express using Netlify.
This is my server.js code:
const express = require("express") const path = require("path") const bodyParser = require("body-parser") const app = express() app.use(bodyParser.urlencoded({extended: false})) app.get("/", (req, res) => { res.sendFile(path.join(process.cwd(), "index.html")) }) app.get("/js", (req, res) => { res.sendFile(path.join(process.cwd(), 'index.js')) }) app.get("/css", (req, res) => { res.sendFile(path.join(process.cwd(), 'index.css')) }) app.get("/data", (req, res) => { res.sendFile(path.join(process.cwd(), "data.html")) }) data = {} app.post("/data/input", (req, res)=>{ let dataPkg = req.body data[dataPkg.id] = dataPkg.name }) app.post("/data/output", (req, res)=>{ res.send(data) }) module.exports = {app};This is my netlify.toml:
[build] publish = "dist" functions = "netlify/functions" [functions] external_node_modules = ["express", "path", "body-parser"] [[redirects]] force = true status = 200 from = "/*" to = "/.netlify/functions/index"And here's how the directory looks:
I deployed the site using Netlify CLI, but when I try to open it, for any file, I get:
Error: ENOENT: no such file or directory, stat '/var/task/data.html'
What do I do?

