【发布时间】:2022-11-22 19:45:34
【问题描述】:
我在 URL 根目录上有一个页面,这是一个用 React 构建的下一页。
现在我也想在 root 上公开一个 API 端点。
`http://localhost:3000/` > points to React page
`http://localhost:3000/foo` > points to the Next API endpoint
`http://localhost:3000/bar` > points to the **same** Next API endpoint
`http://localhost:3000/anything` > points to the **same** Next API endpoint
是否可以重写 API 端点的根路径?如果是,如何?
【问题讨论】:
-
您不能在同一条路线上同时提供 api 和页面。 nextjs.org/docs/api-routes/introduction
-
@Disco 我知道,但我不知道如何编写正确的配置来做到这一点
标签: javascript reactjs typescript next.js