-
Feature requestIs your feature request related to a problem? Please describe.One limitation with the Describe the solution you'd likeMaybe it's possible to decide in each file whether it's a page or an api endpoint, like this: // pages/index.js
import { api, page } from 'next'
// an api endpoint
export default api((req, res) => 'hello')
// a page
export default page((props) => 'hello') Originally posted by @lucleray in #7297 (comment) Or if we could just use the Next router to custom define the API endpoint, that would be great. Describe alternatives you've consideredThis example using Express seems to be the best alternative: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@cseas You should be able to leverage the upcoming custom routes feature to achieve this: rewrites: () => [
{ source: '/my-api-route', destination: '/api/my-api-route' },
] |
Beta Was this translation helpful? Give feedback.
-
@Janpot In your shared snippet will it forward all the query params too? Does it act as a proxy internally like |
Beta Was this translation helpful? Give feedback.
@cseas You should be able to leverage the upcoming custom routes feature to achieve this: