Skip to content

Incoming request URL is not updated to include dynamic route params #35

Closed
@GregBrimble

Description

@GregBrimble

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions