Fix: Use NEXT_PUBLIC_API_URL for all image URLs

This commit is contained in:
AutonetSellCar Deploy
2025-12-30 16:09:06 +09:00
parent a3d5339c84
commit 0ccc2f75c5
5 changed files with 240 additions and 4 deletions

View File

@@ -103,13 +103,15 @@ const FUEL_TYPES = [
{ value: 'LPG', label: 'LPG' },
];
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
// 이미지 URL 변환 (로컬 경로는 백엔드 URL 추가)
const getImageUrl = (url: string | undefined): string => {
if (!url) return '';
if (url.startsWith('http://') || url.startsWith('https://')) {
return url;
}
return `http://localhost:8000${url}`;
return `${API_BASE_URL}${url}`;
};
const YEAR_OPTIONS = Array.from({ length: 15 }, (_, i) => 2024 - i);

View File

@@ -33,13 +33,15 @@ const defaultFormData: BannerFormData = {
car_id: null,
};
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
// 이미지 URL 변환 (로컬 경로는 백엔드 URL 추가)
const getImageUrl = (url: string | undefined): string => {
if (!url) return '';
if (url.startsWith('http://') || url.startsWith('https://')) {
return url;
}
return `http://localhost:8000${url}`;
return `${API_BASE_URL}${url}`;
};
export default function HeroBannersPage() {
@@ -97,7 +99,7 @@ export default function HeroBannersPage() {
.map((b: any) => b.car_id);
if (carIds.length > 0) {
try {
const response = await fetch('http://localhost:8000/api/carmodoo/pdf-status', {
const response = await fetch(`${API_BASE_URL}/api/carmodoo/pdf-status`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(carIds),

View File

@@ -324,6 +324,8 @@ interface BannerCardProps {
height: number;
}
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
// 이미지 URL 변환 (로컬 경로는 백엔드 URL 추가)
const getImageUrl = (url: string): string => {
if (!url) return '';
@@ -331,7 +333,7 @@ const getImageUrl = (url: string): string => {
return url;
}
// 로컬 경로인 경우 백엔드 URL 추가
return `http://localhost:8000${url}`;
return `${API_BASE_URL}${url}`;
};
// Helper to get localized title/subtitle based on language