简体   繁体   English

在下一个 js 中将 pages 文件夹移动到 src 文件夹后,api 不起作用

[英]After moving pages folder to src folder in next js the api is not working

After moving the pages folder to the src folder the API is not working, it was working fine now it shows 404 not found.将 pages 文件夹移动到 src 文件夹后,API 无法正常工作,现在工作正常,显示 404 未找到。

I read the nextJs documentation it says src/pages will be ignored if pages are present in the root directory so I don't know if I need to modify any thing?我阅读了 nextJs 文档,它说如果页面存在于根目录中,src/pages 将被忽略,所以我不知道是否需要修改任何东西?

在此处输入图像描述

在此处输入图像描述

Do I need to modify anything?我需要修改什么吗?

Problem solved, I need to insert the API folder in pages.问题解决了,我需要在页面中插入 API 文件夹。 Any file inside the folder pages/api is mapped to /api/* and will be treated as an API endpoint instead of a page.文件夹 pages/api 中的任何文件都映射到 /api/* 并且将被视为 API 端点而不是页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM