Closed
Description
Next.js attaches dynamic route params as query params. In normal routes, developers usually grab these values from the params
object:
// pages/blog/[slug].ts
export async function getServerSideProps({ params }) {
// params.slug = 'a-blog-slug'
}
But in Edge API routes, there is no such mechanism. In order to grab these values, you have to look at the incoming request URL:
// pages/api/blog/[slug].ts
export default function handler(request) {
const url = new URL(request.url)
url.searchParams.get('slug')
// should be 'a-blog-slug' but is currently null
}
We should pass these handling functions the finalized URL which includes any dynamic route params in the query string.
Metadata
Metadata
Assignees
Labels
No labels