fix: proxy fixed
Build and Deploy / test-backend (push) Successful in 1m31s
Build and Deploy / lint-frontend (push) Successful in 1m54s
Build and Deploy / build-backend (push) Successful in 7s
Build and Deploy / build-frontend (push) Successful in 1m0s
Build and Deploy / deploy (push) Successful in 8s
Build and Deploy / test-backend (push) Successful in 1m31s
Build and Deploy / lint-frontend (push) Successful in 1m54s
Build and Deploy / build-backend (push) Successful in 7s
Build and Deploy / build-frontend (push) Successful in 1m0s
Build and Deploy / deploy (push) Successful in 8s
This commit is contained in:
@@ -9,7 +9,7 @@ export async function proxy(request: NextRequest) {
|
|||||||
const isPublicPath = PUBLIC_PATHS.includes(pathname);
|
const isPublicPath = PUBLIC_PATHS.includes(pathname);
|
||||||
const session = request.nextUrl.searchParams.get("session");
|
const session = request.nextUrl.searchParams.get("session");
|
||||||
|
|
||||||
if (hasRefreshToken && session && pathname === "/login") {
|
if (session && pathname === "/login") {
|
||||||
const accessToken = request.cookies.get("access_token")?.value;
|
const accessToken = request.cookies.get("access_token")?.value;
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, {
|
await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, {
|
||||||
@@ -27,7 +27,11 @@ export async function proxy(request: NextRequest) {
|
|||||||
return NextResponse.redirect(new URL(`/consent?session=${session}`, request.url));
|
return NextResponse.redirect(new URL(`/consent?session=${session}`, request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRefreshToken && (isPublicPath || pathname === "/")) {
|
if (session && pathname === "/consent") {
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasRefreshToken && !session && (isPublicPath || pathname === "/")) {
|
||||||
return NextResponse.redirect(new URL("/me", request.url));
|
return NextResponse.redirect(new URL("/me", request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user