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

Nextjs route matching doesn't match in vercel but does locally #39411

Closed
1 task done
Artrix9095 opened this issue Aug 9, 2022 · 6 comments · Fixed by #39462
Closed
1 task done

Nextjs route matching doesn't match in vercel but does locally #39411

Artrix9095 opened this issue Aug 9, 2022 · 6 comments · Fixed by #39462
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@Artrix9095
Copy link

Artrix9095 commented Aug 9, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: linux
Arch: x64
Version: #653-Microsoft Wed Apr 27 16:06:00 PST 2022
Binaries:
Node: 17.3.0
npm: 8.3.0
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.2
eslint-config-next: 12.2.2
react: 18.2.0
react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome 104.0.5112.81

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

When having a simple file system route like such

/pages

  • /api
  • /user
    • [id].ts
    • login.ts

I've noticed that when running the following configuration locally it works fine. and even when running yarn build && yarn start it still works fine. But when running on vercel. I always get the following error
image

You will see that the path is being matched to the [id] field and not the login field. But when run locally
image

which is extremely odd. A piece of useful information may be that [id].ts is an edge function while login.ts is a serverless function.

Expected Behavior

/api/user/login should match to login.ts and not [id].ts in vercel.

Link to reproduction

None

To Reproduce

npx create-next-app my-app
// /api/user/login.ts

export default async function handler(req, res) {

res.json({hello: 'world'});

}
// /api/user/[id].ts

export const config = {

runtime: 'experimental-edge',

};
export default async function handler(req) {

return new Response('Hello World');

}
npx vercel
@Artrix9095 Artrix9095 added the bug Issue was opened via the bug report template. label Aug 9, 2022
@Artrix9095
Copy link
Author

The 500 error is from the code i have in the [id].ts not taking login as a valid id. in the replication example it will still return 200 but with 'hello world' as the response instead of

{ hello: 'world' }

@Winwardo
Copy link

Winwardo commented Aug 9, 2022

Hi, I was seeing a similar issue #39266 which appears to be fixed in 12.2.5-canary.0, and you've said you're testing on 12.2.2. Does the issue still happen on the latest canary?

@Artrix9095
Copy link
Author

I just tested 12.2.5-canary.0. Still no good

@Artrix9095
Copy link
Author

My main issue is why it this happening specifically on vercel but works fine locally

@balazsorban44
Copy link
Member

balazsorban44 commented Aug 10, 2022

I could actually reproduce this locally, so investigating. 👍 Looks like the edge dynamic routes have a different priority than non-edge routes

@balazsorban44 balazsorban44 added kind: bug Navigation Related to Next.js linking (e.g., <Link>) and navigation. and removed bug Issue was opened via the bug report template. labels Aug 10, 2022
ijjk added a commit that referenced this issue Aug 16, 2022
Fixes #39411
Bug

 Related issues linked using fixes #number
 Integration tests added
 Errors have helpful link attached, see contributing.md

Feature

 Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
 Related issues linked using fixes #number
 Integration tests added
 Documentation added
 Telemetry added. In case of a feature if it's used or not.
 Errors have helpful link attached, see contributing.md

Documentation / Examples

 Make sure the linting passes by running pnpm lint
 The examples guidelines are followed from our contributing doc

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants