Finally fixed origin
This commit is contained in:
@@ -11,7 +11,7 @@ import { java } from "@codemirror/lang-java";
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { LiveRun, LiveRunEvent, LiveRunMove } from "@/modules/live-run/types";
|
import { LiveRun, LiveRunEvent, LiveRunMove } from "@/modules/live-run/types";
|
||||||
import useAction from "@/hook/use-action";
|
import useAction from "@/hook/use-action";
|
||||||
import { getOrigin } from "@/modules/getOrigin";
|
import { getOrigin } from "@/lib/origin/client";
|
||||||
|
|
||||||
type Language =
|
type Language =
|
||||||
| "javascript"
|
| "javascript"
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { headers } from "next/headers";
|
||||||
|
import "server-only";
|
||||||
|
|
||||||
|
export async function getOrigin(): Promise<{ protocol: string; host: string }> {
|
||||||
|
const h = await headers();
|
||||||
|
const host = process.env.ORIGIN || h.get(":authority") || "localhost:3000";
|
||||||
|
const protocol = h.get("x-forwarded-proto") || h.get(":scheme") || "https";
|
||||||
|
|
||||||
|
return { protocol, host };
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
|
import { getOrigin } from "@/lib/origin/server";
|
||||||
import * as Core from "./core";
|
import * as Core from "./core";
|
||||||
import { createClient } from "@/lib/supabase/server";
|
import { createClient } from "@/lib/supabase/server";
|
||||||
import { headers } from "next/headers";
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export async function signInWithGitHub() {
|
export async function signInWithGitHub() {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
|
|
||||||
const h = await headers();
|
const { host, protocol } = await getOrigin();
|
||||||
const host = h.get("host");
|
|
||||||
const protocol = h.get("x-forwarded-proto") ?? "https";
|
|
||||||
|
|
||||||
const { data, error } = await supabase.auth.signInWithOAuth({
|
const { data, error } = await supabase.auth.signInWithOAuth({
|
||||||
provider: "github",
|
provider: "github",
|
||||||
|
|||||||
Reference in New Issue
Block a user