Fix logout (#536)

This commit is contained in:
Chris Weaver 2023-10-07 23:22:27 -07:00 committed by GitHub
parent 478fb4f999
commit d09c320538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
import { getDomain } from "@/lib/redirectSS";
import { getAuthTypeSS, logoutSS } from "@/lib/userSS";
import { NextRequest } from "next/server";
import { NextRequest, NextResponse } from "next/server";
export const POST = async (request: NextRequest) => {
// Directs the logout request to the appropriate FastAPI endpoint.
// Needed since env variables don't work well on the client-side
const authType = await getAuthTypeSS();
return await logoutSS(authType, request.headers);
const response = await logoutSS(authType, request.headers);
if (response && response.ok) {
return NextResponse.redirect(new URL("/auth/login", getDomain(request)));
}
return new Response(null, { status: 204 });
};