gpt4 book ai didi

I have a [slug] "dynamic page" which works perfectly fine in LOCALHOST but shows a 404 in VERCEL and GITHUB(我有一个[slug]“动态页面”,它在LOCALHOST中运行良好,但在VERCEL和GITHUB中显示404)

转载 作者:bug小助手 更新时间:2023-10-22 16:38:59 26 4
gpt4 key购买 nike



I have developed a website with homepage. homepage/blog and homepage/blog/[slug].

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


Everthing works fine in LOCALHOST.
(https://i.stack.imgur.com/8i1RP.jpg)
(https://i.stack.imgur.com/GGhMI.jpg)

Everthing在LOCALHOST中运行良好。(https://i.stack.imgur.com/8i1RP.jpg)(https://i.stack.imgur.com/GGhMI.jpg)


But in GITHUB and VERCEL I get 404 when I try access homepage/blog/[slug] as homepage/blog/1 (https://i.stack.imgur.com/sIrtX.jpg)

但在GITHUB和VERCEL中,当我尝试访问主页/blog/[slug]作为主页/blog/1时,我会得到404(https://i.stack.imgur.com/sIrtX.jpg)


Please check my repo it would help me alot if you can find a solution.

请查看我的回购,如果你能找到解决方案,这将对我有很大帮助。


Repo link:-https://github.com/ManideepVaddepalli/TeamApp-BlogPage-NextJS

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


Live Server:-https://manideepvaddepalli.github.io/TeamApp-BlogPage-NextJS

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


I cant figure out the issue.

我想不通这个问题。


I just want the app to work similar as in LOCALHOST with dynamic pages [slug].

我只想让这个应用程序像在LOCALHOST中一样使用动态页面[slug]。


更多回答

Not 100% sure, but you might want to try nextjs.org/docs/app/api-reference/next-config-js/basePath

不是100%确定,但您可能想尝试nextjs.org/docs/app/api-reference/next-config-js/basePath

Yes, as @CodeThing mentioned, you need to configure basepath, on localhost, you are accessing blog page without any sub directory, however on server you have a sub directory "TeamApp-BlogPage-NextJS"

是的,正如@CodeThing所提到的,你需要配置basepath,在localhost上,你访问的博客页面没有任何子目录,但在服务器上,你有一个子目录“TeamApp BlogPage NextJS”

If I add even my [homepage/blog] page is not showing up. just to mention - My all static directly created pages are working fine . only the [slug] pages are not working in GITHUB and VERCEL where as they are doing fine in LOCALHOST. Please I also gave the link to my repo You can download and check it in your local environment. Hope you find a solution

如果我添加,甚至我的[主页/博客]页面都不会显示。仅举一例-我的所有静态直接创建的页面都运行良好。只有[slug]页面在GITHUB和VERCEL中不起作用,因为它们在LOCALHOST中做得很好。请注意,我还提供了我的回购链接。您可以在本地环境中下载并查看。希望你能找到解决方案

and a reminder i have replaced the anchor tags with "./" path instead of "/". If this could be helpful in debug

还有一个提醒,我已经用“./”路径代替了“/”。如果这对调试有帮助

Please provide enough code so others can better understand or reproduce the problem.

请提供足够的代码,以便其他人能够更好地理解或重现问题。

优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com