mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-16 18:25:17 +02:00
invoke auth0 middleware only when relevant
This commit is contained in:
parent
44f8088d9b
commit
59a631e6df
1 changed files with 2 additions and 4 deletions
|
|
@ -8,11 +8,9 @@ const corsOptions = {
|
||||||
|
|
||||||
|
|
||||||
export async function middleware(request: NextRequest, event: NextFetchEvent) {
|
export async function middleware(request: NextRequest, event: NextFetchEvent) {
|
||||||
const authRes = await auth0.middleware(request);
|
|
||||||
|
|
||||||
// Check if the request path starts with /api/auth/
|
// Check if the request path starts with /api/auth/
|
||||||
if (request.nextUrl.pathname.startsWith('/auth')) {
|
if (request.nextUrl.pathname.startsWith('/auth')) {
|
||||||
return authRes;
|
return await auth0.middleware(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the request path starts with /api/
|
// Check if the request path starts with /api/
|
||||||
|
|
@ -44,7 +42,7 @@ export async function middleware(request: NextRequest, event: NextFetchEvent) {
|
||||||
request.nextUrl.pathname.startsWith('/onboarding')) {
|
request.nextUrl.pathname.startsWith('/onboarding')) {
|
||||||
// Skip auth check if USE_AUTH is not enabled
|
// Skip auth check if USE_AUTH is not enabled
|
||||||
if (process.env.USE_AUTH === 'true') {
|
if (process.env.USE_AUTH === 'true') {
|
||||||
return authRes;
|
return await auth0.middleware(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue