Skip to content

Commit 84a81cc

Browse files
AdamWAdamWozniewski
authored andcommitted
Update repos for async-auth
update package.json for ver5
1 parent dd625b1 commit 84a81cc

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed
File renamed without changes.

asynchronous-authorization/vercel-ai-next-js/src/app/globals.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
@tailwind base;
2-
@tailwind components;
3-
@tailwind utilities;
1+
@import "tailwindcss";
42

53
@layer base {
64
:root {
Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
1-
import { NextRequest, NextResponse } from "next/server";
2-
import { auth0 } from "./lib/auth0";
1+
import type { NextRequest } from "next/server"
32

4-
const APP_SESSION_COOKIE = "appSession";
3+
import { auth0 } from "./lib/auth0"
54

65
export async function middleware(request: NextRequest) {
7-
const { pathname } = request.nextUrl;
8-
9-
if (pathname.startsWith("/auth")) {
10-
return auth0.middleware(request);
11-
}
12-
13-
try {
14-
const session = await auth0.getSession(request);
15-
if (!session) {
16-
return NextResponse.redirect(new URL("/auth/login", request.url));
17-
}
18-
return NextResponse.next();
19-
} catch {
20-
const redirect = NextResponse.redirect(new URL("/auth/login", request.url));
21-
redirect.cookies.set(APP_SESSION_COOKIE, "", {
22-
path: "/",
23-
httpOnly: true,
24-
maxAge: 0,
25-
});
26-
return redirect;
27-
}
6+
return await auth0.middleware(request);
287
}
298

309
export const config = {
3110
matcher: [
32-
"/((?!_next/static|_next/image|images|favicon\\.(?:ico|png)|sitemap\\.xml|robots\\.txt|$).*)",
11+
/*
12+
* Match all request paths except for the ones starting with:
13+
* - _next/static (static files)
14+
* - _next/image (image optimization files)
15+
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
16+
*/
17+
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
3318
],
34-
};
19+
}

0 commit comments

Comments
 (0)