Vercel deployment issue 404: NOT_FOUND when using middleware on dynamic routes
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home Single Language
Binaries:
Node: 16.13.2
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.1.5-canary.1
react: 18.0.0
react-dom: 18.0.0
What browser are you using? (if relevant)
Microsoft Edge
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
I am deploying my apps to Vercel
. but got a 404 not found page when I have _middleware.ts
on dynamic routes and when I’m visiting the dynamic routes.
It works fine in my local
My middleware just return the NextResponse,next()
like this
import { NextResponse } from "next/server";
const middleware = () => {
return NextResponse.next();
};
export default middleware;
Expected Behavior
- Page can be visited when deployed to Vercel without a 404 issue
To Reproduce
I created a small repository to reproduce
https://github.com/bryantobing12/try-next-middleware
To test. when visiting /test
it’s returning 404 not found when deployed to vercel. Only happening in dynamic routes
i have this route /[customerSlug] https://try-next-middleware.vercel.app/test
It works fine When visiting static page
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
404 Page not found Vercel Deployment - using dynamic ...
When they create an application and then try to preview it, they are prompted with the 404 error. But if I trigger a...
Read more >Custom 404 Page – Vercel Docs
Create a custom 404 page and deploy with Vercel. ... You can configure your router to handle the case when no route is...
Read more >Data Fetching: getServerSideProps - Next.js
Learn how to fetch data on each request with Next.js. ... params : If this page uses a dynamic route, params contains the...
Read more >Different History modes - Vue Router
Not to worry: To fix the issue, all you need to do is add a simple catch-all fallback route to your server. If...
Read more >Next.js 12.2 Overview: Middleware, Layouts, and more
Next.js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more.0:00 Intro1:50 Agenda2:30 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A fix has been released to
canary
, please test it out (npm i next@canary
)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.