Node.js Firebase部署以angular作为前端框架的nodejs应用程序
如何配置使用angular作为前端框架和多个路由文件的express.js应用程序,以及通过服务级别api调用相互通信的服务器和angular,以便通过firebase主机在firebase中部署 现在,我很难找到正确的方法来配置firebase.json文件和要在firebase中部署的整个项目 现在,当我部署我的应用程序时,只有dist文件夹中的index.html页面通过api或任何方式进入Node.js Firebase部署以angular作为前端框架的nodejs应用程序,node.js,angular,firebase,express,firebase-hosting,Node.js,Angular,Firebase,Express,Firebase Hosting,如何配置使用angular作为前端框架和多个路由文件的express.js应用程序,以及通过服务级别api调用相互通信的服务器和angular,以便通过firebase主机在firebase中部署 现在,我很难找到正确的方法来配置firebase.json文件和要在firebase中部署的整个项目 现在,当我部署我的应用程序时,只有dist文件夹中的index.html页面通过api或任何方式进入 const express = require("express"); const app = e
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}`));
我需要使用firebase函数吗?请帮忙
编辑
我们能否以任何方式包含云功能来帮助托管此应用程序?我以前尝试过,但不可能做到这一点。我已成功解决了此问题,但不是直接解决
- 我设法在一个单独的文件夹中做角度前端工作,一旦构建完成,我就构建一个生产版本
- 将dist文件夹中的内容复制到firebase项目的公用文件夹中
- 在firebase.json文件中单独管理路由
- 在云函数中的index.js文件中,我们将调用index.html,就像在mean stack应用程序中一样