fix: API URL 처리 로직 개선
- 프로덕션 URL에서 /api를 제거하는 로직을 수정하여, 호스트명의 /api까지 제거되는 버그를 방지하였습니다. - API_BASE_URL 및 NEXT_PUBLIC_API_URL에서 문자열 끝의 /api만 제거하도록 정규 표현식을 사용하였습니다. - FileViewerModal 컴포넌트에서 다운로드 URL 생성 시에도 동일한 수정이 적용되었습니다.
This commit is contained in:
parent
33db3933d8
commit
43541a12c9
|
|
@ -62,7 +62,10 @@ export const getFullImageUrl = (imagePath: string): string => {
|
|||
}
|
||||
|
||||
// SSR 또는 알 수 없는 환경에서는 API_BASE_URL 사용 (fallback)
|
||||
const baseUrl = API_BASE_URL.replace("/api", "");
|
||||
// 주의: 프로덕션 URL이 https://api.vexplor.com/api 이므로
|
||||
// 단순 .replace("/api", "")는 호스트명의 /api까지 제거하는 버그 발생
|
||||
// 반드시 문자열 끝의 /api만 제거해야 함
|
||||
const baseUrl = API_BASE_URL.replace(/\/api$/, "");
|
||||
if (baseUrl.startsWith("http://") || baseUrl.startsWith("https://")) {
|
||||
return `${baseUrl}${imagePath}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,9 @@ export const getDirectFileUrl = (filePath: string): string => {
|
|||
}
|
||||
|
||||
// SSR 또는 알 수 없는 환경에서는 환경변수 사용 (fallback)
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL?.replace("/api", "") || "";
|
||||
// 주의: 프로덕션 URL이 https://api.vexplor.com/api 이므로
|
||||
// 단순 .replace("/api", "")는 호스트명의 /api까지 제거하는 버그 발생
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL?.replace(/\/api$/, "") || "";
|
||||
if (baseUrl.startsWith("http://") || baseUrl.startsWith("https://")) {
|
||||
return `${baseUrl}${filePath}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,9 @@ export const FileViewerModal: React.FC<FileViewerModalProps> = ({ file, isOpen,
|
|||
}
|
||||
} else {
|
||||
// 기타 파일은 다운로드 URL 사용
|
||||
const url = `${API_BASE_URL.replace("/api", "")}/api/files/download/${file.objid}`;
|
||||
// 주의: 프로덕션 URL이 https://api.vexplor.com/api 이므로
|
||||
// 끝의 /api만 제거해야 호스트명이 깨지지 않음
|
||||
const url = `${API_BASE_URL.replace(/\/api$/, "")}/api/files/download/${file.objid}`;
|
||||
setPreviewUrl(url);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -284,7 +284,9 @@ export const FileViewerModal: React.FC<FileViewerModalProps> = ({ file, isOpen,
|
|||
}
|
||||
} else {
|
||||
// 기타 파일은 다운로드 URL 사용
|
||||
const url = `${API_BASE_URL.replace("/api", "")}/api/files/download/${file.objid}`;
|
||||
// 주의: 프로덕션 URL이 https://api.vexplor.com/api 이므로
|
||||
// 끝의 /api만 제거해야 호스트명이 깨지지 않음
|
||||
const url = `${API_BASE_URL.replace(/\/api$/, "")}/api/files/download/${file.objid}`;
|
||||
setPreviewUrl(url);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue