我正在尝试设置Angular 9 Universal + Firebase 应用程序。 我已经将Universal 包添加到我的项目中,并添加了Firebase云函数以支持SSR。 这是我的云函数代码:
import * as functions from 'firebase-functions';
import * as path from 'path';
const universal = require(path.resolve(__dirname, '../dist/server/main')).app;
export const ssr = functions.runWith({ memory: "2GB", timeoutSeconds: 120 }).https.onRequest(universal);
我的 Firebase 配置:
{
"hosting": {
"public": "dist/browser",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"function": "ssr"
}
]
}
}
编译没有错误,应用程序似乎正常工作,但路由不起作用。主路由(
/
)加载得很好,我可以导航到其他路由而没有错误,但是如果我尝试在新标签页中打开任何其他路由(例如/books
),或重新加载已经打开的路由,就会收到超时异常。这里是截图:
![error](https://istack.dev59.com/muhtB.webp)