Github 页面仅显示部署 NextJs 应用程序后的自述文件

问题描述 投票:0回答:1

我使用 next js (使用 nextjs 14 )制作了这个基本的电子商务 Web 应用程序,我想使用 github 页面部署它,我按照 youtube 上的教程进行操作,并尝试使用 gh-page 分支和 github 操作进行部署,最终都失败了当您访问网站时仅显示自述文件。我确实在源代码处将分支从主页面更改为 gh-pages,但仍然相同。任何人都可以帮助我吗? [github 页面链接 --] [1]: https://noelkasemi.github.io/strength-palace/ (https://i.stack.imgur.com/VzvyB.png) [我的 github 存储库 --] [1]:https://github.com/noelkasemi/strength-palace

我尝试使用 github actions 进行部署并得到相同的结果。我尝试使用分支,并且确实使用了主页面和 gh-pages 一次又一次相同的结果。预先感谢任何可能提供帮助的人!!

javascript reactjs github next.js github-pages
1个回答
0
投票

我从未使用过 Github 页面,但初步看来它需要静态应用程序才能运行。您的存储库仅包含应用程序,没有任何构建。

将您的

next.config.js
更改为:

/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig

至:

 /** @type {import('next').NextConfig} */
const nextConfig = {
    output: "exports", // lightweight but no dynamic routes & api support
    // output: "standalone", // bulkier but supports dynamic routes & api
}

module.exports = nextConfig

然后使用以下方法构建您的应用程序:

npm run build

它将生成一个构建文件夹,使用新生成的构建文件夹重试。确保您的路径配置正确。

© www.soinside.com 2019 - 2024. All rights reserved.