Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,634 changes: 1,628 additions & 6 deletions Playproof/package-lock.json

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions Playproof/src/features/mypage/gameData/api/overfastApi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// src/features/mypage/gameData/api/overfastApi.ts

import axios from "axios";

const overwatchClient = axios.create({
baseURL: "/api/overwatch",
timeout: 15_000,
});
import { overwatchClient } from "@/services/axios";

export type OverfastPlayerSummary = {
player_id: string;
Expand Down
7 changes: 1 addition & 6 deletions Playproof/src/features/mypage/gameData/api/riotApi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// src/features/mypage/gameData/api/riotApi.ts

import axios from "axios";

const api = axios.create({
baseURL: "/api/riot",
timeout: 10_000,
});
import { riotKrClient as api } from "@/services/axios";

/* =========================
* DTO
Expand Down
5 changes: 1 addition & 4 deletions Playproof/src/features/mypage/gameData/api/valorantApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ type ValorantMatchDetailResponse = {
players: ValorantMatchPlayer[];
};

const client = axios.create({
baseURL: "/api/valorant",
headers: { "Content-Type": "application/json" },
});
import { valorantClient as client } from "@/services/axios";

export const valorantApi = {
async getMmrByRiotId(params: GetMmrParams): Promise<ValorantMmrResponse> {
Expand Down
5 changes: 3 additions & 2 deletions Playproof/src/features/team/hooks/useAzitChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { useAzitSocket, type ChatMessage, type ApiError } from "./useAzitSocket"
import { getChatMessages } from "@/features/team/api/chatApi";
import { useAuthStore } from "@/store/authStore";

const API_BASE_URL =
import.meta.env.VITE_API_BASE_URL ?? "https://myfit.my";
const API_BASE_RAW = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
const API_BASE = API_BASE_RAW.replace(/\/$/, "");
const API_BASE_URL = API_BASE ? `${API_BASE}/api` : "/api";

export const useAzitChat = (
params: {
Expand Down
6 changes: 4 additions & 2 deletions Playproof/src/features/team/hooks/useAzitPageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ export function useAzitPageLogic() {
const { accessToken, userId: authUserId, nickname: authNickname, setAuth } = useAuthStore();
const isAutoLoggingIn = React.useRef(false);

const apiBaseUrl =
const API_BASE_RAW =
((import.meta as unknown as { env?: Record<string, unknown> }).env?.VITE_API_BASE_URL as string | undefined)?.trim() ||
"https://myfit.my";
"";
const API_BASE = API_BASE_RAW.replace(/\/$/, "");
const apiBaseUrl = API_BASE ? `${API_BASE}/api` : "/api";

const currentUserId = authUserId ? String(authUserId) : FALLBACK_USER_ID;

Expand Down
7 changes: 6 additions & 1 deletion Playproof/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
import axios from "axios";
import { useAuthStore } from "@/store/authStore";

// 환경변수 기반 API 루트
const API_BASE_RAW = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
const API_BASE = API_BASE_RAW.replace(/\/$/, "");
const API_PREFIX = API_BASE ? `${API_BASE}/api` : "/api";

// baseURL은 프로젝트 환경에 맞게 바꿔줘
export const api = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL ?? "",
baseURL: API_PREFIX,
headers: {
"Content-Type": "application/json",
...(import.meta.env.VITE_ACCESS_TOKEN
Expand Down
23 changes: 17 additions & 6 deletions Playproof/src/services/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,32 @@ const noCacheHeaders = {
Expires: "0",
};

// 환경변수 기반 API 루트. 예: "https://myfit.my" 또는 빈 문자열(로컬 프록시 사용)
const API_BASE_RAW = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? "";
const API_BASE = API_BASE_RAW.replace(/\/$/, "");
const API_PREFIX = API_BASE ? `${API_BASE}/api` : "/api";

// ✅ 기본 공용 클라이언트 (default export로 사용)
export const appClient = axios.create({
baseURL: "",
baseURL: API_BASE || "",
headers: noCacheHeaders,
});

// 1. Riot 한국 서버
export const riotKrClient = axios.create({
baseURL: "/api/riot",
baseURL: `${API_PREFIX}/riot`,
headers: noCacheHeaders,
});

// 2. Riot 아시아 서버
export const riotAsiaClient = axios.create({
baseURL: "/api/riot-asia",
baseURL: `${API_PREFIX}/riot-asia`,
headers: noCacheHeaders,
});

// 3. Nexon 클라이언트
export const nexonClient = axios.create({
baseURL: "/api/nexon",
baseURL: `${API_PREFIX}/nexon`,
headers: {
"x-nxopen-api-key": import.meta.env.VITE_NEXON_API_KEY,
...noCacheHeaders,
Expand All @@ -39,13 +44,19 @@ export const nexonClient = axios.create({

// 4. Steam 클라이언트
export const steamClient = axios.create({
baseURL: "/api/steam",
baseURL: `${API_PREFIX}/steam`,
headers: noCacheHeaders,
});

// 5. Overwatch 클라이언트
export const overwatchClient = axios.create({
baseURL: "/api/overwatch",
baseURL: `${API_PREFIX}/overwatch`,
headers: noCacheHeaders,
});

// Valorant 클라이언트
export const valorantClient = axios.create({
baseURL: `${API_PREFIX}/valorant`,
headers: noCacheHeaders,
});

Expand Down
9 changes: 9 additions & 0 deletions Playproof/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ export default defineConfig({
},
dedupe: ['react', 'react-dom'],
},
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
secure: false,
},
},
},
})