From 6b9a0721262764109ede786144636894fd2dbb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=AE?= Date: Wed, 8 Jul 2026 05:45:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=B4=EB=B6=80=20=EB=84=A4=ED=8A=B8?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=EC=97=90=EC=84=9C=20api=20=EC=A0=91=EA=B7=BC?= =?UTF-8?q?=20=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20ip=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai-server/backend/main.py | 11 +++++++++++ unity-client/Assets/Scripts/BattleManager.cs | 2 +- unity-client/Assets/Scripts/NPCDialogueManager.cs | 2 +- unity-client/Assets/Scripts/Player.cs | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ai-server/backend/main.py b/ai-server/backend/main.py index d065b30..a1403de 100644 --- a/ai-server/backend/main.py +++ b/ai-server/backend/main.py @@ -15,7 +15,18 @@ async def lifespan(app: FastAPI): yield print("서버 종료") +from fastapi.middleware.cors import CORSMiddleware + app = FastAPI(title="로그라이크 AI 백엔드", version="1.0", lifespan=lifespan) +# 같은 네트워크 상의 모든 외부 기기(PC, 폰 등) 브라우저 접속 허용 +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + # 라우터 등록 app.include_router(game_router) \ No newline at end of file diff --git a/unity-client/Assets/Scripts/BattleManager.cs b/unity-client/Assets/Scripts/BattleManager.cs index ebdc0bd..39fbe29 100644 --- a/unity-client/Assets/Scripts/BattleManager.cs +++ b/unity-client/Assets/Scripts/BattleManager.cs @@ -64,7 +64,7 @@ public class BattleManager : MonoBehaviour Debug.Log($"[Battle] 스킬 프롬프트 전송 시도: \"{skillPrompt}\""); // 1. FastAPI 서버의 generate-skill API 호출 (플레이어 레벨 파라미터에는 Generation 세대값 전달) - string url = "http://127.0.0.1:8000/api/game/generate-skill"; + string url = "http://192.168.1.7:8000/api/game/generate-skill"; int playerLevel = (player != null) ? player.Generation : 1; SkillCreateRequest requestData = new SkillCreateRequest diff --git a/unity-client/Assets/Scripts/NPCDialogueManager.cs b/unity-client/Assets/Scripts/NPCDialogueManager.cs index e8147ee..048bf52 100644 --- a/unity-client/Assets/Scripts/NPCDialogueManager.cs +++ b/unity-client/Assets/Scripts/NPCDialogueManager.cs @@ -69,7 +69,7 @@ public class NPCDialogueManager : MonoBehaviour } // FastAPI의 NPC 대화 조회 엔드포인트 URL 구성 - string url = $"http://127.0.0.1:8000/api/game/npc-dialogue?current_generation={currentGeneration}"; + string url = $"http://192.168.1.7:8000/api/game/npc-dialogue?current_generation={currentGeneration}"; Debug.Log($"[Dialogue] NPC 대사 조회 요청 전송: {url}"); using (UnityWebRequest request = UnityWebRequest.Get(url)) diff --git a/unity-client/Assets/Scripts/Player.cs b/unity-client/Assets/Scripts/Player.cs index e379854..6d0e891 100644 --- a/unity-client/Assets/Scripts/Player.cs +++ b/unity-client/Assets/Scripts/Player.cs @@ -243,7 +243,7 @@ public class Player : MonoBehaviour // 백엔드로부터 다음 세대 번호를 받아와 랜덤 이름과 매핑하는 코루틴 private System.Collections.IEnumerator GetNextGenerationFromServer() { - string url = "http://127.0.0.1:8000/api/game/generation/next"; + string url = "http://192.168.1.7:8000/api/game/generation/next"; using (UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.Get(url)) { @@ -286,7 +286,7 @@ public class Player : MonoBehaviour // 백엔드로 완성된 사망 기록을 전송하는 코루틴 private System.Collections.IEnumerator SendDeathReport(string cause) { - string url = "http://127.0.0.1:8000/api/game/death"; + string url = "http://192.168.1.7:8000/api/game/death"; AncestorDeathCreate requestData = new AncestorDeathCreate {