Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.5] optional catch all routes req.query.params behavior is different when deployed on vercel (works in dev, works in 9.4.4) #15579

Closed
vvo opened this issue Jul 28, 2020 · 10 comments · Fixed by #15593 or #22676
Assignees
Milestone

Comments

@vvo
Copy link
Member

vvo commented Jul 28, 2020

Bug report

Describe the bug

Hi, just tried to upgrade from 9.4.4 to 9.5.0. I was previously using the experimental optionalCatchAll flag. On 9.5.0 my optional catch-all routes are working in dev mode (next dev) but no more working when deployed on Vercel.

The issue is that req.query.params value is different between Vercel and dev mode when using optional catch-all routes.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Given a project structure of:

- project
- api/
- api/organizations/
- api/organizations/[organizationId]
- api/organizations/[organizationId]/teams/
- api/organizations/[organizationId]/teams/[[...params]].js

When calling https://example.com/organizations/200/teams on vercel (9.5.0):

  • req.query.params value: [""]

When calling https://localhost/organizations/200/teams on next dev (9.5.0):

  • req.query.params value: undefined

When calling https://example.com/organizations/200/teams on vercel (9.4.4):

  • req.query.params value: undefined

When calling https://localhost/organizations/200/teams on next dev (9.4.4):

  • req.query.params value: undefined

Expected behavior

Both vercel and next dev should send the same value for req.query.params, maybe sticking to undefined or anything else that makes sense given current APIs.

System information

  • OS: macOS
  • Version of Next.js: 9.5.0
  • Version of Node.js: 12.8.3

Additional context

n/a

@vvo vvo changed the title [9.5] optional catch all routes picking up wrong file when deployed on vercel (works in dev, works in 9.4.4) [9.5] optional catch all routes behavior is different when deployed on vercel (works in dev, works in 9.4.4) Jul 28, 2020
@vvo vvo changed the title [9.5] optional catch all routes behavior is different when deployed on vercel (works in dev, works in 9.4.4) [9.5] optional catch all routes req.query.params behavior is different when deployed on vercel (works in dev, works in 9.4.4) Jul 28, 2020
@Janpot
Copy link
Contributor

Janpot commented Jul 28, 2020

Does next build => next start behave the same way?

@Timer Timer added this to the iteration 6 milestone Jul 28, 2020
@Timer Timer assigned Timer and ijjk and unassigned Timer Jul 28, 2020
@ijjk ijjk added the point: 2 label Jul 28, 2020
@NBruhno
Copy link

NBruhno commented Jul 28, 2020

I have a similar issue. If I build it locally and run it with next start, the routes work, same with vercel dev. But deployed on Vercel, it fails with a 502 initially and continuos tries returns a 405 for me because the method is gone. Just to add, this used to work just fine in the last version while it was experimental for me as well, if that helps.

@stevez86
Copy link

I have a possibly related issue for a monorepo setup after upgrading to 9.5. I think it has to do with the routes in now.json not working correctly. I have this;

{
   ...
  "builds": [{ "src": "brand/next.config.js", "use": "@now/next" }],
  "routes": [{ "src": "/(.*)", "dest": "/brand/$1", "continue": true }]
}

Everything works in development, but on vercel my APIs fail and the homepage gets redirected to /brand. Please let me know what you need from me or if this should be a separate issue.

@kodiakhq kodiakhq bot closed this as completed in #15593 Jul 29, 2020
kodiakhq bot pushed a commit that referenced this issue Jul 29, 2020
This updates collecting dynamic route params on Vercel to make sure that missing optional dynamic routes are undefined. Additional tests for this mode have also been added to ensure the params are being collected properly

Closes: #15579
@Timer
Copy link
Member

Timer commented Jul 30, 2020

This was just fixed in 9.5.1, please upgrade!

@vvo
Copy link
Member Author

vvo commented Jul 30, 2020

I confirm this fixed my issue. Thanks

@NBruhno
Copy link

NBruhno commented Jul 30, 2020

My issue appears to be resolved with the patch as well. Appreciate the quick fix!

LauraBeatris pushed a commit to LauraBeatris/next.js that referenced this issue Sep 1, 2020
This updates collecting dynamic route params on Vercel to make sure that missing optional dynamic routes are undefined. Additional tests for this mode have also been added to ensure the params are being collected properly

Closes: vercel#15579
@vvo
Copy link
Member Author

vvo commented Mar 2, 2021

Hey there, this bug is back again today on Vercel. Without updating Next.js, req.query.params went from undefined to "".

I created a ticket on Vercel side.

Next.js version: 10.0.7

@ijjk
Copy link
Member

ijjk commented Mar 2, 2021

Hi @vvo, this has been fixed in the latest version of Next.js v10.0.8-canary.13, please update and give it a try!

@vvo
Copy link
Member Author

vvo commented Mar 2, 2021

Thanks, I'll wait for full release and upgrade from there. For now I just switched from params === undefined to !params :)

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
7 participants