Next.js Discord

Discord Forum

Query params are getting stripped in Vercel

Unanswered
Yellow Wagtail posted this in #help-forum
Open in Discord
Yellow WagtailOP
Hey guys!

I am struggling with a weird thing.
I've got an API route GET app/api/preview/route.ts where I am trying to have a look at the query params in the url so then I can turn on draftMode and redirect to the proper slug.

Problem I am facing is that while on localhost I am able to see the query params, when I deploy on Vercel the thing doesn't work anymore. It looks like something happens with Vercel and strips away the query params. A weird thing I noticed is that if I pass params that start with _ those are not stripped away.

Sample of code that I use to have a look at the params:

export async function GET(request: NextRequest) {
  const { searchParams } = new URL(request.url);
  let slug = searchParams.get('slug');
...
}


Anyone has any idea what might be happening?

4 Replies

do npx next info and paste here.

Also the next version written in the package.json file.

Pin the version to the latest version and test. If that doesnt work, try canary. Otherwise you should probably open up a issue on GitHub.
Yellow WagtailOP
I was running on next: 13.5.3
I upgraded to canary now and tested, behaves just the same, here's the npx next info:
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
Binaries:
  Node: 18.16.0
  npm: 10.1.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 13.5.4-canary.9
  eslint-config-next: 13.5.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A