next.js icon indicating copy to clipboard operation
next.js copied to clipboard

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

Open artrixdotdev opened this issue 2 years ago • 4 comments

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

artrixdotdev avatar Aug 09 '22 06:08 artrixdotdev

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' }

artrixdotdev avatar Aug 09 '22 06:08 artrixdotdev

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?

Winwardo avatar Aug 09 '22 08:08 Winwardo

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

artrixdotdev avatar Aug 09 '22 17:08 artrixdotdev

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

artrixdotdev avatar Aug 09 '22 17:08 artrixdotdev

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

balazsorban44 avatar Aug 10 '22 12:08 balazsorban44

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[bot] avatar Sep 16 '22 00:09 github-actions[bot]