nextjs api route request.query is undefined

export async function GET(
  req: NextApiRequest,
  res: NextApiResponse<GoogleOAuthCodeExchangeApiResponse>
) {
  console.info(`request query ${req.query}`)
  const code = req.query.code

logs:
request query undefined

I followed the docs and req.query should be {} by default but here is
undefined
, why?
Solution
If you're using the App Router, the req type is NextRequest, or even just simply Request. query doesn't exist on the requests from App Router.
Was this page helpful?