NextJS和Firebase Hosting-直接访问动态路线,重定向到生产中的index.js
我没有找到有关此行为的任何文档,但是这里是...
基本上我已经建立了一个index.js页面和一个动态[address] .js页面。
我在这里面对的问题是,每当我访问[地址] .js页面时,以“/helloworld”为端点,当我完全期望[address] .js的内容显示时,我都会重定向到index.js。 。
这只有在部署到Firebase托管后才发生,而不是在Local主机环境中发生的。
作为解决方法,我将此代码段添加到index.js上的使用效率方法中,以路由返回[地址] .js .js .js。这感觉非常效率低下。
const path = router.asPath;
if (
path &&
(path !== "/[address]")
) {
Router.push(`${path}`);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里为问题提供一些清晰和理解。
事实证明,我在动态路由上的问题与NextJS无关,而与Firebase平台上的静态托管站点无关。
这是一篇文章,有助于涵盖对燃料托管中动态路线的担忧:https://medium.com/hackernoon/firebase-to-the-rescue-dynamic-routing-via-hosting-functions-integration-aef888ddf311
Here to provide some clarity and understanding around the problem.
It turns out that my issue with dynamic routing has nothing to do with NextJS and more to do with static hosting of sites on the firebase platform.
Here's an article that helps to cover this concern about dynamic routes on firebase hosting: https://medium.com/hackernoon/firebase-to-the-rescue-dynamic-routing-via-hosting-functions-integration-aef888ddf311