dev-eclipse.netlify.app
.
I get this error when i go to my api that is supposed to send dashboard.html as the response:
Error: ENOENT: no such file or directory, stat '/var/task/src/dashboard.html'
This is my project directory:
Api.js:
const express = require("express");
const serverless = require("serverless-http");
const path = require("path");
const dotenv = require('dotenv');
dotenv.config();
const app = express();
const router = express.Router();
router.get("/dashboard", (req, res) => {
const password = req.query.password;
if (password === process.env.ADMIN_PASSWORD) {
res.sendFile(path.join(__dirname, 'dashboard.html'));
} else {
res.status(403).send("Forbidden");
}
})
app.use('/.netlify/functions/api', router);
module.exports.handler = serverless(app);