Fixed auth

This commit is contained in:
2026-01-03 22:48:05 +01:00
parent 07e19b29e4
commit 8c45fca826
+11 -1
View File
@@ -1,11 +1,21 @@
"use server"; "use server";
import { client } from "@/core/auth/oauth"; import { client } from "@/core/auth/oauth";
import { headers } from "next/headers";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
export default async function redirectAuth() { export default async function redirectAuth() {
// Get headers of the incoming request
const hdrs = await headers();
// Get protocol and host
const host = hdrs.get("host");
const proto = hdrs.get("x-forwarded-proto") || "http";
const baseUrl = `${proto}://${host}`;
const authorizationUri = client.authorizeURL({ const authorizationUri = client.authorizeURL({
redirect_uri: "http://localhost:3000/api/auth/callback", redirect_uri: `${baseUrl}/api/auth/callback`,
scope: "user:email", scope: "user:email",
state: "random_state_string", state: "random_state_string",
}); });