fix: 가맹몰 추가 이미지가 저장 뒤 사라져 보이던 원인(HEAD 401)을 GET 두드리기로 고친다
백엔드 인증 예외가 GET에만 열려 있어 이미지 존재 확인 HEAD가 전부 401로 떨어졌고, 그래서 저장한 추가 이미지 묶음이 수정 화면에 한 장도 안 보이고 다시 저장하면 묶음 id까지 지워졌다. GET으로 상태만 보고 본문은 바로 끊는다(dev 실물 묶음으로 1장 검출 확인). Co-Authored-By: Claude Opus 5
@2ed6030195bf83cabd1f472159241a88e333a9b2
--- lib/data/repositories/merchant-detail-repository.ts
+++ lib/data/repositories/merchant-detail-repository.ts
... | ... | @@ -143,8 +143,11 @@ |
| 143 | 143 |
|
| 144 | 144 |
/** |
| 145 | 145 |
* 묶음 안의 이미지 수를 알려 주는 API가 없다(보고함). fileSn이 1부터 빈틈없이 붙으므로 최대 장수를 |
| 146 |
- * 한꺼번에 HEAD로 두드려 이어지는 앞부분만 취한다 — 차례로 두드리면 장수만큼 왕복이 늘어난다. |
|
| 146 |
+ * 한꺼번에 두드려 이어지는 앞부분만 취한다 — 차례로 두드리면 장수만큼 왕복이 늘어난다. |
|
| 147 | 147 |
* 없는 번호는 백엔드가 500으로 답한다. |
| 148 |
+ * |
|
| 149 |
+ * HEAD가 아니라 GET으로 두드린다 — 백엔드 인증 예외가 GET에만 열려 있어 HEAD는 401이다. 본문은 |
|
| 150 |
+ * 상태만 보고 바로 끊는다. |
|
| 148 | 151 |
*/ |
| 149 | 152 |
async function probeImageUrls(fileId: string | null): Promise<string[]> {
|
| 150 | 153 |
if (!fileId) return []; |
... | ... | @@ -154,7 +157,9 @@ |
| 154 | 157 |
const exists = await Promise.all( |
| 155 | 158 |
candidates.map(async (url) => {
|
| 156 | 159 |
try {
|
| 157 |
- return (await fetch(url, { method: 'HEAD', cache: 'no-store' })).ok;
|
|
| 160 |
+ const response = await fetch(url, { method: 'GET', cache: 'no-store' });
|
|
| 161 |
+ await response.body?.cancel().catch(() => undefined); |
|
| 162 |
+ return response.ok; |
|
| 158 | 163 |
} catch {
|
| 159 | 164 |
return false; |
| 160 | 165 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?