Skip to content

Commit

Permalink
always control the x-workos-session header (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatheson committed Mar 28, 2024
1 parent ffd2ef4 commit 6c3f4f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/session.ts
Expand Up @@ -30,6 +30,8 @@ async function updateSession(request: NextRequest, debug: boolean) {
// Record that the request was routed through the middleware so we can check later for DX purposes
newRequestHeaders.set(middlewareHeaderName, 'true');

newRequestHeaders.delete(sessionHeaderName);

// If no session, just continue
if (!session) {
return NextResponse.next({
Expand Down Expand Up @@ -77,7 +79,9 @@ async function updateSession(request: NextRequest, debug: boolean) {
return response;
} catch (e) {
console.warn('Failed to refresh', e);
const response = NextResponse.next();
const response = NextResponse.next({
request: { headers: newRequestHeaders },
});
response.cookies.delete(cookieName);
return response;
}
Expand Down

0 comments on commit 6c3f4f3

Please sign in to comment.