reactjs - 使用 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. 但是,即使我为我的云函数使用不同的函数目录,我也会看到相同的错误。无论如何我可以修复它吗?
解决方案
这是可能的,但您不能使用云功能提供静态资产。您需要结合使用 firebase 功能和 firebase 托管。
Firebase 的人已经考虑过这一点,并且您也有一个可用的实现。
检查以下文档:
注意:使用云功能时需要考虑延迟。
当一个新实例处理它的第一个请求时,响应时间会受到影响,这称为冷启动
推荐阅读
- javascript - 这个字符串作为函数参数是如何工作的(没有括号?!)?
- kubernetes - 无法拉取镜像仓库不存在或可能需要“docker login”:
- mongodb - Powershell MongoDb - 无法将“System.Object[]”类型的对象转换为 MongoDB.Driver.ProjectionDefinition`1[MongoDB.Bson.BsonDocument]'
- r - 设置训练和测试数据集时的分层随机样本
- python - 将数据框分成 3 个新的数据框
- php - 如何修复 PHP exec 未运行,但命令在 linux 终端上有效?
- python - 如何通过选择前 n 行来创建更小的熊猫数据框
- excel - Microsoft Excel:具有间接引用的动态数据验证列表
- lua - 如何将相同的代码放在 Lua 中的不同元方法中?
- python - 熊猫:选择具有最大列值的所有行