1- import { NextRequest , NextResponse } from "next/server" ;
21import { headers } from "next/headers" ;
32import { cookies } from "next/headers" ;
43import { redirect } from "next/navigation" ;
@@ -41,28 +40,28 @@ export const getSession = async (): Promise<Session | null> => {
4140 }
4241} ;
4342
44- export const signIn = async ( redirectTo ?: string ) : Promise < NextResponse > => {
43+ export const signIn = async ( redirectTo ?: string ) : Promise < Response > => {
4544 const config = getGlobalConfig ( ) ;
4645 const session = await getSession ( ) ;
4746 const cookieStore = await cookies ( ) ;
4847 const headersList = await headers ( ) ;
4948 const redirectUri = redirectTo ?? headersList . get ( "Referer" ) ?? "/" ;
5049 await cookieStore . set ( "REDIRECT_AFTER" , redirectUri , { sameSite : "lax" , httpOnly : true , secure : true } ) ;
5150 if ( session ) {
52- return NextResponse . json ( { message : "Already signed in" } , { status : 200 } ) ;
51+ return Response . json ( { message : "Already signed in" } , { status : 200 } ) ;
5352 }
5453 const signInURL = `https://discord.com/api/oauth2/authorize?client_id=${ config . clientId } &redirect_uri=${ encodeURIComponent ( config . redirectUri ) } &response_type=code&scope=${ config . scopes . join ( " " ) } ` ;
5554 return redirect ( signInURL ) ;
5655} ;
5756
58- export const signOut = async ( ) : Promise < NextResponse > => {
57+ export const signOut = async ( ) : Promise < Response > => {
5958 const cookieStore = await cookies ( ) ;
6059 const token = cookieStore . get ( "AUTH_SESSION" ) ?. value ;
6160 if ( ! token ) {
62- return NextResponse . json ( { message : "Not signed in" } , { status : 401 } ) ;
61+ return Response . json ( { message : "Not signed in" } , { status : 401 } ) ;
6362 }
6463
6564 cookieStore . delete ( "AUTH_SESSION" ) ;
6665
67- return NextResponse . json ( { message : "Signed out successfully" } , { status : 200 } ) ;
66+ return Response . json ( { message : "Signed out successfully" } , { status : 200 } ) ;
6867} ;
0 commit comments