如何在 Firebase 托管上部署 next.js 应用程序? [英] How to deploy next.js app on Firebase Hosting?

查看:26
本文介绍了如何在 Firebase 托管上部署 next.js 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Firebase 托管上部署 next.js 应用.但我不明白哪些文件要推送到服务器.当我运行 npm run build 并将构建文件夹推送到 firebase 时.但给出了 No index.html file found 的错误.

I am trying to deploy next.js app on Firebase hosting. But I don't understand which files to push to the server. When I run npm run build and pushed the build folder to firebase. But gives error that No index.html file found.

这是构建文件夹的输出图像.我刚刚创建了一个用于测试目的的简单组件.

Here is the image of output of build folder. I have just created a simple component for testing purposes.

构建命令的输出

推荐答案

检查 这个先出来.这是 Next.js 团队在其 GitHub 存储库中提供的官方示例.

示例背后的想法:

我们的目标是使用 Firebase 托管重写规则在 Firebase Cloud Functions 上托管 Next.js 应用,以便我们的应用从我们的 Firebase 托管 URL 提供.每个单独的页面包都在对执行初始服务器渲染的 Cloud Function 的新调用中提供.

The goal is to host the Next.js app on Firebase Cloud Functions with Firebase Hosting rewrite rules so our app is served from our Firebase Hosting URL. Each individual page bundle is served in a new call to the Cloud Function which performs the initial server render.

这是基于 https://github.com/geovanisouza92/serverless-firebase 的工作https://github.com/jthegedus/firebase-functions-next-example 如此处所述.

This is based off of the work at https://github.com/geovanisouza92/serverless-firebase and https://github.com/jthegedus/firebase-functions-next-example as described here.

PS:我知道发布链接作为答案不是最好的方法,但我的代表权不足以将其作为评论.

PS : I know posting links as answers is not the best way, but my rep power is not enough to put this as a comment.

这篇关于如何在 Firebase 托管上部署 next.js 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆