Next.js Discord

Discord Forum

Help. 502 ROUTER CANNOT MATCH error occured

Unanswered
English Spot posted this in #help-forum
Open in Discord
English SpotOP
First of all, Sorry for my weak english.
When I deploy my project on vercel, this issue occurring.
There was no problem on local environment.

in build result, below pages are generated as SSG.
/emergency-card/Basic
├ ├ /emergency-card/MedicalConditions
├ ├ /emergency-card/Medication
...
https://pre-ver.easy-doc.app/emergency-card/Basic

when I access this page, this error occured. how can I solve it?

nextjs version : 13.4.1

11 Replies

English SpotOP
ohno Version upgrading makes compile error.
what error?
English SpotOP
There was a package issue, but it was resolved right away. Let me check deploy result.
no version update doesnt work
updated to 14.0.4
next build & next start work in locally?
English SpotOP
Yes vercel environment only occured.
Buy the way I found solution. middleware.ts behind us...
const middleware = (request: NextRequest) => {
const isMaintenance: boolean = process.env.NEXT_PUBLIC_IS_MAINTENANCE === 'true';
if (isMaintenance) {
return NextResponse.redirect(new URL('/maintenance/', request.url));
} else {
// return NextResponse.next();
}
};

export const config = {
matcher: '/((?!img|maintenance)):path*',
};

export default middleware;

I don't know why upper code makes this issue.
@Ray Thanks reply!