How can I configure an express.js app that uses Angular as the front end framework and multiple route files and the server and Angular communicating with each other via service level api calls, so that it can be deployed in Firebase via Firebase hosting.
I am having difficulty in getting a correct way of configuring firebase.json file and the overall project to be deployed in Firebase.
As of now when I deploy my app only the index.html page in the dist folder is coming in either via api or in any ways.
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
const cors = require("cors");
const path = require("path");
const http = require("http");
// const functions = require('firebase-functions')
const server = http.createServer(app);
const authRoutes = require("./api/auth");
const dataRoutes = require("./api/data");
const deviceRoutes = require('./api/device');
app.use(cors());
app.options("*", cors());
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: false
})
);
app.use(express.static(path.join(__dirname, "dist")));
const port = process.env.PORT || "1337";
app.set("port", port);
app.use("/api/auth", authRoutes);
app.use("/api/data", dataRoutes);
app.use("/api/device", deviceRoutes);
app.get("*", function (req, res) {
res.sendFile(path.join(__dirname, "dist/index.html"));
});
// exports.app = functions.https.onRequest(app);
server.listen(port, () => console.log(`Server running on localhost:${port}`));
Do I need to use Firebase functions?
Edit
Can we include cloud functions in any ways to help in hosting this app?