vercel / next.js

The React Framework
https://nextjs.org
MIT License
123.53k stars 26.35k forks source link

static export with trailingSlash: true - query params dropped #24483

Open oldo opened 3 years ago

oldo commented 3 years ago

What version of Next.js are you using?

10.0.5

What version of Node.js are you using?

12.13.0

What browser are you using?

Brave

What operating system are you using?

macOS

How are you deploying your application?

next export -> S3

Describe the Bug

I have a static site that I am deploying to an S3 bucket with npm run build && npm run export and I have trailingSlash: true set in my next config file.

I am finding that if I go to a route on my localhost like so:

http://localhost:3000/users/login?query=test

then the trailing slash gets inserted and query params passed on:

http://localhost:3000/users/login/?query=test

However I am finding on production that if I go to:

https://test.com/users/login?query=test

I get directed to the following and the query params are lost:

https://test.com/users/login/

Expected Behavior

I would expect the behaviour to be the same on my localhost and production, and I would expect that the query params are passed along.

To Reproduce

Just export any site with npm run build && npm run export and set trailingSlash: true in you next.config.js.

renzit commented 1 year ago

did you find a way to solve this?

guilhermefront commented 1 year ago

Should be working now on the latest version.

jeroenoomsNL commented 1 year ago

This is still not working with next export and trailingSlash: true. Version 13.3.0. I've tested this with a local export on my own device, as well as on AWS S3.

sanderkoenders commented 1 year ago

Seeing the same behaviour as well on our nextjs export with trailingSlash: true. Using version 13.3.0.

20manas commented 7 months ago

This is still an issue. I'm using trailing slashes everywhere but when using <Link> tag, next seems to be fetching resources without trailing slash which prompts a 302 from S3. In the 302, query params are being removed.

HelaGone commented 2 months ago

Hi everyone. I'm having a similar issue with trailinSlash:true In my case it's adding a trailingSlash at the end of my query params: https://example.com/discover/?id=12345-qwerty/. This is happening in the generateMtadata function. My server returns the right value in the alternates.canonical but when rendered in the client It's adding the trailing slash at the end of the value of the query param. <link rel="canonical" href="https://example.com/discover/?id=f0e60bb2-6f17-4486-a7a8-2aa35056f104/"/> Any related issue or fix?