fix: [document] PDF 생성 시 cross-origin 이미지 누락 수정

- /api/image-proxy 프록시 라우트 추가 (CORS 우회)
- convertImagesToBase64에서 cross-origin 이미지를 프록시로 fetch
This commit is contained in:
김보곤
2026-03-22 08:58:58 +09:00
parent 12d3111629
commit a8aa159cf0
2 changed files with 52 additions and 1 deletions

View File

@@ -173,8 +173,13 @@ export function DocumentViewer({
const src = img.src;
if (!src || src.startsWith('data:')) return;
// cross-origin 이미지는 서버 프록시를 통해 fetch (CORS 우회)
const isSameOrigin = src.startsWith(window.location.origin) || src.startsWith('/');
const fetchUrl = isSameOrigin ? src : `/api/image-proxy?url=${encodeURIComponent(src)}`;
try {
const response = await fetch(src);
const response = await fetch(fetchUrl);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const blob = await response.blob();
const dataUrl = await new Promise<string>((resolve, reject) => {
const reader = new FileReader();