#middleware cause 400 error on routes

34 messages · Page 1 of 1 (latest)

inland idol
#

Hi
I have a hot problem in production.
My middleware file cause 400 bad requeat error in app rourtes!
And this problem is shown after we moved to HTTPS from HTTP. everything was OK on HTTP.

I forced to remove middleware file for now...
Do you have any idea how to fix this??

drifting hearthBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

cedar hatchBOT
# inland idol Hi I have a hot problem in production. My middleware file cause 400 bad requeat...
Please add more information to your question

Your question currently does not have sufficient information for people to be able to help. Please add more information to help us help you, for example: relevant code snippets, a reproduction repository, and/or more detailed error messages. See more info on how to ask a good question in https://discord.com/channels/752553802359505017/1138338531983491154 and #welcome message.

obsidian kite
#

You would have to share your middlewarenwith us

#

Middleware*

idle oracle
#

This feels like a problem in the reverse proxy, next js https is experimental so i would have to see your architecture and middleware to conclude @inland idol

inland idol
#

@idle oracle @obsidian kite

I have this problem even if i have a simple middleware like :

export function middleware(request: NextRequest) {
   return NextResponse.next()
}

My structure is :

src
   app
   components
   middleware.ts
idle oracle
#

Ok but how is the traffic routed to the server

inland idol
#

I did not understand

idle oracle
#

Is the next instance in https mode

#

Im isking if the traffic is decrypted before it hits the server

inland idol
#

I did not touch my next config for https.
I was always worked with http.
The funny thing is when i remove my middleware, problem is gone and routes are ahown.
But when i put middleware my route and chunks are not load.
I have no idea what to do ;((

idle oracle
#

Huh well that is essential info

inland idol
#

What info yoh need? Tell me to give it to you

idle oracle
#

Wait

#

Do you have a matcher

inland idol
#

Nope.
I was added matcher too. no effect

idle oracle
#

What

#

This may be a bug

#

Yeah bro sorry this is the end of my knowledge

inland idol
#

Bug of what? Next?

#

Thanks bro 🙂

idle oracle
obsidian kite
#

export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
/
'/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).
)',
],
}

#

If this doesn’t work

#

Then yeah not sure

#

In middleware add that*^

#

At bottom

inland idol
#

Still have the problem :((

#

Could it be the cloudflare issue??

idle oracle
inland idol
#

Problem solved!
It was from webserver and haproxy(DevOps issues)

Thank you guys

inland idol