Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用express时发生firebase服务错误(已启用区域)_Javascript_Angular_Firebase_Google Cloud Functions_Firebase Tools - Fatal编程技术网

Javascript 使用express时发生firebase服务错误(已启用区域)

Javascript 使用express时发生firebase服务错误(已启用区域),javascript,angular,firebase,google-cloud-functions,firebase-tools,Javascript,Angular,Firebase,Google Cloud Functions,Firebase Tools,我创建了一个函数ssr,它使用express服务器来处理请求,但是当我通过http请求运行该函数时http://localhost:4201//us-central1/ssr,我得到一个错误: import * as functions from "firebase-functions"; const app = require("../server"); //this function works export const test = functions.https.onRequest

我创建了一个函数
ssr
,它使用express服务器来处理请求,但是当我通过http请求运行该函数时
http://localhost:4201//us-central1/ssr
,我得到一个错误:

import * as functions from "firebase-functions";
const app = require("../server");  

//this function works
export const test = functions.https.onRequest((request, response) => {
  response.send("firebase function works");
});

//this function doesn't work
export const ssr = functions.https.onRequest(app);
我认为这个错误是由angular zone
import“zone.js/dist/zone节点”引起的

server.ts(简化):

TypeError:func不是函数
运行函数时(firebase tools\lib\emulator\functionsEmulatorRuntime.js:621:20)
在firebase tools\lib\emulator\functionsEmulatorRuntime.js:596:19

在Generator.next(

你解决问题了吗?我在一个基本的express项目上也得到了同样的结果否,@AAverin。。。
import "zone.js/dist/zone-node";
import express from "express";
import * as bodyParser from "body-parser";
import cors from "cors"; 


const PORT = process.env.PORT || 4200;
const DIST_FOLDER = join(process.cwd(), "./dist/browser"); 

const {
  AppServerModuleNgFactory,
  LAZY_MODULE_MAP,
  ngExpressEngine,
  provideModuleMap
} = require("./dist/server/main");

app.engine(
  "html",
  ngExpressEngine({
    bootstrap: AppServerModuleNgFactory,
    providers: [provideModuleMap(LAZY_MODULE_MAP)]
  })
);

app.set("view engine", "html");
app.set("views", DIST_FOLDER);
app.use(bodyParser.json());
app.use(cors());


app.get("*", (req, res) => {
  res.render("index", { req });
});


app.listen(PORT, () => {
  console.log(`Node Express server listening on http://localhost:${PORT}`);
});

export { app }; //for firebase

TypeError: func is not a function
    at runFunction (firebase-tools\lib\emulator\functionsEmulatorRuntime.js:621:20)
    at firebase-tools\lib\emulator\functionsEmulatorRuntime.js:596:19
    at Generator.next (<anonymous>)
    at firebase-tools\lib\emulator\functionsEmulatorRuntime.js:7:71
    at new ZoneAwarePromise (zone.js\dist\zone-node.js:931:29)
    at __awaiter (firebase-tools\lib\emulator\functionsEmulatorRuntime.js:3:12)
    at runFunction (firebase-tools\lib\emulator\functionsEmulatorRuntime.js:593:12)
    at firebase-tools\lib\emulator\functionsEmulatorRuntime.js:620:15
    at Generator.next (<anonymous>)
    at firebase-tools\lib\emulator\functionsEmulatorRuntime.js:7:71