Skip to content

Commit

Permalink
feat: add userSbId for island
Browse files Browse the repository at this point in the history
  • Loading branch information
JangAyeon committed Feb 21, 2024
1 parent a84e299 commit f37757f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export async function middleware(request: NextRequest) {
const {
data: { user },
} = await supabase.auth.getUser()
const { pathname } = request.nextUrl
const { pathname, searchParams } = request.nextUrl

// console.log("pathname", pathname)
// console.log("user", user)
// 회원가입/로그인 페이지는 이미 로그인된 유저라면 메인 페이지로 리다이렉트
if (userAgent && !pathname.includes("favicon"))
if (pathname === "/auth") {
Expand All @@ -26,6 +26,12 @@ export async function middleware(request: NextRequest) {
return NextResponse.redirect(new URL(`/`, request.url))
}
return NextResponse.next()
} else if (pathname === "/island") {
if (!searchParams.get("id") && user) {
return NextResponse.redirect(
new URL(`/island?id=${user.id}`, request.url)
)
}
}

if (!session) {
Expand Down

0 comments on commit f37757f

Please sign in to comment.