我有一个[slug]“动态页面”,它在 LOCALHOST 中工作得很好,但在 VERCEL 和 GITHUB 中显示 404

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

我开发了一个带有主页的网站。 主页/博客和主页/博客/[slug]。

LOCALHOST 中一切正常。 (https://i.sstatic.net/8i1RP.jpg) (https://i.sstatic.net/GGhMI.jpg)

但是在 GITHUB 和 VERCEL 中,当我尝试访问 homepage/blog/[slug] 作为 homepage/blog/1 时,我得到 404 (https://i.sstatic.net/sIrtX.jpg)

请检查我的存储库,如果您能找到解决方案,这将对我有很大帮助。

回购链接:-https://github.com/ManideepVaddepalli/TeamApp-BlogPage-NextJS

实时服务器:-https://manideepvaddepalli.github.io/TeamApp-BlogPage-NextJS

我无法弄清楚这个问题。

我只是希望该应用程序的工作方式与具有动态页面的 LOCALHOST 类似 [slug]。

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

如果您的项目中有 vercel.json 文件,只需将其删除即可。然而,这会破坏 404 页面。

{
  "rewrites": [{ "source": "/(.*)", "destination": "/error" }]
}

这段代码破坏了动态路由

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