首页 > 解决方案 > 使用 firebase-functions 部署基于反应的 SSR 应用程序时出错

问题描述

在对应用程序进行一些修改后,我正在尝试在最初从https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router分叉的 firebase 中部署我的 SSR 应用程序。当我这样做时效果很好,但当我这样做时会sudo firebase serve --only functions,hosting抛出错误firebase deploy。可重现的仓库是https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router,它有一个 package.json https://github.com/subhendukundu/template-react-ssr/ tree/feature/react-router/public 我也使用公共目录作为我的函数目录,https://github.com/subhendukundu/template-react-ssr/blob/feature/react-router/firebase.json. 但是,即使我为我的云函数使用不同的函数目录,我也会看到相同的错误。无论如何我可以修复它吗?

标签: reactjsfirebasegoogle-cloud-functionsfirebase-hostingnext.js

解决方案


这是可能的,但您不能使用云功能提供静态资产。您需要结合使用 firebase 功能和 firebase 托管。

Firebase 的人已经考虑过这一点,并且您也有一个可用的实现。

检查以下文档:

注意:使用云功能时需要考虑延迟。

当一个新实例处理它的第一个请求时,响应时间会受到影响,这称为冷启动

更多信息


推荐阅读