Skip to content

Commit db7ffea

Browse files
authored
chore: add env var for social login (#7251)
1 parent 489b5ab commit db7ffea

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#### Prowler UI Configuration ####
66
PROWLER_UI_VERSION="stable"
7-
SITE_URL=http://localhost:3000
7+
AUTH_URL=http://localhost:3000
88
API_BASE_URL=http://prowler-api:8080/api/v1
99
NEXT_PUBLIC_API_DOCS_URL=http://prowler-api:8080/api/v1/docs
1010
AUTH_TRUST_HOST=true

ui/app/api/auth/callback/github/route.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { NextResponse } from "next/server";
44

55
import { signIn } from "@/auth.config";
6+
import { baseUrl } from "@/lib/helper";
67

78
export async function GET(req: Request) {
89
const { searchParams } = new URL(req.url);
@@ -42,14 +43,14 @@ export async function GET(req: Request) {
4243
accessToken: access,
4344
refreshToken: refresh,
4445
redirect: false,
45-
callbackUrl: "/",
46+
callbackUrl: `${baseUrl}/`,
4647
});
4748

4849
if (result?.error) {
4950
throw new Error(result.error);
5051
}
5152

52-
return NextResponse.redirect(new URL("/", req.url));
53+
return NextResponse.redirect(new URL("/", baseUrl));
5354
} catch (error) {
5455
// eslint-disable-next-line no-console
5556
console.error("SignIn error:", error);

ui/app/api/auth/callback/google/route.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { NextResponse } from "next/server";
44

55
import { signIn } from "@/auth.config";
6+
import { baseUrl } from "@/lib/helper";
67

78
export async function GET(req: Request) {
89
const { searchParams } = new URL(req.url);
@@ -42,14 +43,14 @@ export async function GET(req: Request) {
4243
accessToken: access,
4344
refreshToken: refresh,
4445
redirect: false,
45-
callbackUrl: "/",
46+
callbackUrl: `${baseUrl}/`,
4647
});
4748

4849
if (result?.error) {
4950
throw new Error(result.error);
5051
}
5152

52-
return NextResponse.redirect(new URL("/", req.url));
53+
return NextResponse.redirect(new URL("/", baseUrl));
5354
} catch (error) {
5455
// eslint-disable-next-line no-console
5556
console.error("SignIn error:", error);

ui/lib/helper.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { getTask } from "@/actions/task";
22
import { AuthSocialProvider, MetaDataProps, PermissionInfo } from "@/types";
33

4+
export const baseUrl = process.env.AUTH_URL || "http://localhost:3000";
5+
46
export const getAuthUrl = (provider: AuthSocialProvider) => {
57
const config = {
68
google: {

0 commit comments

Comments
 (0)