You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an nextjs edge api that returns a ReadableStream. It works great, but when i wrap it in a withMiddlewareAuthRequired to gate the api for users only the stream does not end up being returned.
Reproduction
the api code looks something like this. I have abstracted out the stream logic in to a getStream() function for simplicity:
Support for producing a response in Next.js middleware was added after we added withMiddlewareAuthRequired - so it does not currently support this use case. Let me schedule some work to fix this.
In the meantime, you should be able to use getSession as a workaround.
import{NextResponse}from"next/server";import{getSession}from"@auth0/nextjs-auth0/edge";exportasyncfunctionmiddleware(req){constres=NextResponse.next();constsession=awaitgetSession(req,res);if(session){// logged in}else{// redirect to login}}
Checklist
Description
I have an nextjs edge api that returns a ReadableStream. It works great, but when i wrap it in a withMiddlewareAuthRequired to gate the api for users only the stream does not end up being returned.
Reproduction
the api code looks something like this. I have abstracted out the stream logic in to a
getStream()
function for simplicity:SDK version
2.4.0
Next.js version
13.3.0
Node.js version
18
The text was updated successfully, but these errors were encountered: