gpt4 book ai didi

Middleware not executing on Nextjs 13.4 app routing(中间件未在Nextjs 13.4应用程序路由上执行)

转载 作者:bug小助手 更新时间:2023-10-27 20:26:42 25 4
gpt4 key购买 nike



I have a problem.
My middleware doesn't get executed...
This is my code:

我有个问题。我的中间件没有被执行...这是我的代码:


export const config = {
matcher: '/api/:function*',
};

This is the config I gave, it should only execute when the API gets a request.
I have the middleware.ts file inside my app/ folder.
Does someone know why this isn't working. I have the app routing version without the src/ folder selected.

这是我给出的配置,它应该只在API收到请求时执行。我的app/文件夹中有middleware.ts文件。有人知道为什么这不起作用吗。我的应用程序路由版本没有选择src/文件夹。


更多回答
优秀答案推荐

Place middleware.ts in the src/ directory. It should be on the same level as app directory.

将midleware.ts放在src/目录中。它应该在同一级别的应用程序目录。


更多回答

I love you <3 Nextjs made a very bad documentation. I though it would work by just putting it into the app folder.

我爱你<3 Nextjs做了一个非常糟糕的文档。我以为只要把它放到应用程序文件夹里就行了。

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