Next.js 13 应用程序目录路由分组抛出“提供的非匹配路径(/public)”错误。

huangapple go评论61阅读模式
英文:

Next.js 13 App Directory route grouping throwing "Non matching path () provided for /(public)"

问题

我正在尝试为每个路由组创建不同的布局,有3个布局:auth、dashboard和public。但是当我对路由进行分组时,出现了错误消息"提供了不匹配的路径(),用于/(public)"。以下是我的文件夹结构:

Next.js 13 应用程序目录路由分组抛出“提供的非匹配路径(/public)”错误。

结构是否有问题?还是我漏掉了什么?

英文:

I'm trying to create a different layout for each route groups, there's 3 layouts: auth, dashboard, and public. But when I group the routes, the error "Non matching path () provided for /(public)" occured. Here's my folder structure:

Next.js 13 应用程序目录路由分组抛出“提供的非匹配路径(/public)”错误。

Is there something wrong with the structure? Or is there something i missed?

答案1

得分: 2

在NextJs版本13.4.12中使用Turbopack时,我遇到了这个错误。简单来说,通过从package.json脚本中移除"dev": "next dev ---turbo"并替换为"dev": "next dev."来再次使用webpack。至少在目前的beta版本中,可能会出现一些错误。

英文:

In NextJs version 13.4.12 with Turbopack, I'm getting that error. Simply, use webpack again by removing "dev": "next dev ---turbo" from the package.json script and replace it with "dev": "next dev." At least for now, in beta, it may have some errors.

答案2

得分: 0

根据我的理解和文件,文件夹 (public) 仅用于分组,不会被视为路径,为了使路由可访问,您需要将 page.js 放入另一个文件夹,例如 (public)/public/page.js。这将使其可以通过 /public 路由访问。

英文:

As far as my understanding and according to the documents, the folder (public ) is only for grouping and won't be consider a path, in order to make the route accessible you need to put the page.js inside another folder eg: (public)/public/page.js This will make it accessible by /public route.

huangapple
  • 本文由 发表于 2023年7月23日 18:32:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747766.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定