I've been working on deploying an Angular app called "test-app" to Heroku via GitHub and everything seems to be going smoothly, except for setting up the express routing function.
I've tried different paths, but Heroku keeps throwing this error:
Error: ENOENT: no such file or directory, stat '/app/test-app/index.html'
Here is my "server.js" file:
const express = require("express");
const path = require("path");
const app = express();
app.use(express.static(__dirname + "/dist"));
app.get("/*", function(req, res) {
res.sendFile(path.join(__dirname, "/dist/test-app/index.html"));
});
app.listen(process.env.PORT || 8080, () => {
console.log("Connected to the server");
});
I believe I might have made a mistake in the "path join" section. Could someone please assist me with this?