-
Notifications
You must be signed in to change notification settings - Fork 1
[FIX] 개발 환경 프록시 순환 참조 문제 해결 및 설정 개선 #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| import type { ClubDetail } from '../types/clubDetail'; | ||
|
|
||
| export const fetchClubDetail = async (clubId: number): Promise<ClubDetail> => { | ||
| const url = `/api/clubs/${clubId}`; | ||
| const res = await fetch(url); | ||
| const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}`; | ||
| const response = await fetch(url); | ||
|
|
||
| if (!res.ok) { | ||
| if (!response.ok) { | ||
| throw new Error('동아리 상세 정보를 가져오는데 실패했습니다.'); | ||
| } | ||
|
|
||
| return res.json() as Promise<ClubDetail>; | ||
| return response.json() as Promise<ClubDetail>; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ export default ({ mode }: ConfigEnv) => { | |
| server: { | ||
| proxy: { | ||
| '/api': { | ||
| target: env.VITE_API_BASE_URL, | ||
| target: env.VITE_PROXY_TARGET, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify environment variable configuration. The proxy target change correctly addresses the circular reference issue. However, ensure that Run the following script to verify the environment configuration: 🏁 Script executed: #!/bin/bash
# Description: Verify .env.development exists and contains required variables
if [ -f ".env.development" ]; then
echo "=== .env.development contents ==="
cat .env.development
echo ""
# Check for required variables
if grep -q "VITE_PROXY_TARGET" .env.development; then
echo "✓ VITE_PROXY_TARGET is defined"
else
echo "✗ VITE_PROXY_TARGET is NOT defined"
fi
if grep -q "VITE_API_BASE_URL" .env.development; then
echo "✓ VITE_API_BASE_URL is defined"
else
echo "✗ VITE_API_BASE_URL is NOT defined"
fi
else
echo "✗ .env.development file not found"
fiLength of output: 33 🏁 Script executed: #!/bin/bash
# List all environment configuration files and check for required variables
echo "=== Env files found ==="
ls -1 .env* 2>/dev/null || echo "No .env files found"
for file in .env*; do
if [ -f "$file" ]; then
echo ""
echo "=== Checking $file ==="
grep -H "VITE_PROXY_TARGET" "$file" || echo "✗ VITE_PROXY_TARGET not found in $file"
grep -H "VITE_API_BASE_URL" "$file" || echo "✗ VITE_API_BASE_URL not found in $file"
fi
doneLength of output: 43 Enforce definition or fallback for VITE_PROXY_TARGET and VITE_API_BASE_URL 🤖 Prompt for AI Agents |
||
| changeOrigin: true, | ||
| secure: false, | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 반환 타입으로
Promise<ClubResponse>가 명시되어 있지만,response.json()은Promise<any>를 반환하므로 타입 안정성이 떨어질 수 있습니다. 다른 API 파일(예:src/pages/user/ClubDetail/api/clubDetail.ts)에서는as Promise<Type>과 같이 명시적 타입 캐스팅을 사용하고 있습니다. 코드베이스 전체의 일관성과 타입 안정성을 위해 아래와 같이 수정하는 것을 제안합니다.이러한 변경을 타입 캐스팅이 누락된 다른 API 호출 함수(예:
fetchCommentsincomments.ts,fetchDetailApplicationindetailApplication.ts등)에도 일관되게 적용하는 것을 고려해 보세요.