Skip to content

Commit 1158f84

Browse files
committed
fix: Proper redirect handling
1 parent cb0dc9b commit 1158f84

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "dist/index.js",
77
"files": ["dist"],
88
"license": "WTFPL",
9-
"version": "0.1.2",
9+
"version": "0.1.3",
1010
"type": "module",
1111
"repository": {
1212
"type": "git",

src/server-actions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22
import { cookies } from "next/headers";
3+
import { redirect } from "next/navigation";
34
import { type Session, getGlobalConfig } from "./index";
45
import jwt from "jsonwebtoken";
56

@@ -17,14 +18,14 @@ export const getSession = async (): Promise<Session | null> => {
1718
}
1819
};
1920

20-
export const signIn = async (req: NextRequest): Promise<NextResponse> => {
21+
export const signIn = async (): Promise<NextResponse> => {
2122
const config = getGlobalConfig();
2223
const session = await getSession();
2324
if (session) {
2425
return NextResponse.json({ message: "Already signed in" }, { status: 200 });
2526
}
2627
const signInURL = `https://discord.com/api/oauth2/authorize?client_id=${config.clientId}&redirect_uri=${encodeURIComponent(config.redirectUri)}&response_type=code&scope=${config.scopes.join(" ")}`;
27-
return NextResponse.redirect(signInURL, 302);
28+
return redirect(signInURL);
2829
};
2930

3031
export const signOut = async (): Promise<NextResponse> => {

0 commit comments

Comments
 (0)