Skip to content

Commit

Permalink
[failsafe] block demo user outside development if added to prod datab…
Browse files Browse the repository at this point in the history
…ase by mistake
  • Loading branch information
eriktaubeneck committed Jun 8, 2024
1 parent e455b17 commit 574902d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ export async function middleware(request: NextRequest) {
email: '[email protected]',
password: 'password',
})
console.log(data);
return response
}
const {
data: { user },
} = await supabase.auth.getUser();

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

0 comments on commit 574902d

Please sign in to comment.