Skip to content

Commit

Permalink
clean up error handling for local auth bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck committed Jun 8, 2024
1 parent b0524f0 commit 0337937
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export async function middleware(request: NextRequest) {
password: dummyPassword
});
if (signUpError) {
console.error(signInError);
throw(signUpError);
console.error('Sign-in error:', signInError);
console.error('Sign-up error:', signUpError);
throw new Error('Failed to handle local development auth bypass.');
}
}
return response
Expand All @@ -79,7 +80,7 @@ export async function middleware(request: NextRequest) {
} = await supabase.auth.getUser();

const allowedPathsRegex = new RegExp(`^(/|/login|/auth/callback|/docs/.+)$`);
if ((!user || user.email === '[email protected]') && !allowedPathsRegex.test(request.nextUrl.pathname)) {
if (!user && !allowedPathsRegex.test(request.nextUrl.pathname)) {
const url = request.nextUrl.clone();
url.pathname = `/404`;
return NextResponse.rewrite(url);
Expand Down

0 comments on commit 0337937

Please sign in to comment.