From de6bdf6aa059da61b915e926231c41fe05df23f2 Mon Sep 17 00:00:00 2001 From: sjwie Date: Fri, 3 May 2024 15:35:35 +0900 Subject: [PATCH] remove DOMAIN env, initial fit fetching in /unity --- .env | 3 +-- .env.production | 3 +-- app/fit/route.ts | 5 +++-- app/unity/page.tsx | 15 +-------------- app/unity/unity.tsx | 4 +--- 5 files changed, 7 insertions(+), 23 deletions(-) diff --git a/.env b/.env index f7ceccd..fd33a88 100644 --- a/.env +++ b/.env @@ -1,2 +1 @@ -# placing my env here -DOMAIN=http://localhost:3000 \ No newline at end of file +# placing my env here \ No newline at end of file diff --git a/.env.production b/.env.production index a9531f7..fd33a88 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1 @@ -# placing my env here -DOMAIN=https://nextjs-test-rnd.vercel.app \ No newline at end of file +# placing my env here \ No newline at end of file diff --git a/app/fit/route.ts b/app/fit/route.ts index bcabb4e..cab1349 100644 --- a/app/fit/route.ts +++ b/app/fit/route.ts @@ -1,5 +1,6 @@ import { NextRequest } from "next/server"; import { frame, ohg } from "../constant"; +import { LengthType } from "../types"; export async function GET(request: NextRequest) { const { searchParams } = new URL(request.url); @@ -17,8 +18,8 @@ export async function GET(request: NextRequest) { (Object.keys(frameObject.length).reduce( (prev, curr) => prev + - (ohgObject.length[curr as keyof typeof ohgObject.length] - - frameObject.length[curr as keyof typeof frameObject.length]) ** + (ohgObject.length[curr as keyof LengthType] - + frameObject.length[curr as keyof LengthType]) ** 2, 0, ) / diff --git a/app/unity/page.tsx b/app/unity/page.tsx index 56aaabd..b4a1929 100644 --- a/app/unity/page.tsx +++ b/app/unity/page.tsx @@ -6,25 +6,12 @@ const getItem = async () => { return await Promise.resolve({ option, ohg, frame }); }; -const getInitMatch = async () => { - return await fetch(`${process.env.DOMAIN}/fit?o=0&f=0`, { - method: "GET", - }); -}; - export default async function UnityComponent() { const { option, ohg, frame } = await getItem(); - const res = await getInitMatch(); - const initMatch = (await res.json()) as { match: number }; return ( - + ); } diff --git a/app/unity/unity.tsx b/app/unity/unity.tsx index c3c33d7..69ff44f 100644 --- a/app/unity/unity.tsx +++ b/app/unity/unity.tsx @@ -16,7 +16,6 @@ const unityConfigBuilder: (path: string) => UnityConfig = (path) => ({ }); export default function UnityComponent({ - initMatch, option = [], ohg = [], frame = [], @@ -28,12 +27,11 @@ export default function UnityComponent({ }[]; ohg: ObjectType[]; frame: ObjectType[]; - initMatch: number; }) { const params = useSearchParams(); const p = params.get("p"); const [selectedIndex, setSelectedIndex] = useState({ ohg: 0, frame: 0 }); - const [match, setMatch] = useState(initMatch); + const [match, setMatch] = useState(100); if (!p || isNaN(Number(p))) location.href = "/unity?p=0"; const { unityProvider, isLoaded, loadingProgression, UNSAFE__unityInstance } =