fix:영상 미리보기 CORS 에러 해결

preview에서 GCS redirect 대신 서명URL을 JSON 반환(?url=1)하여
video 태그에서 직접 사용. storage.googleapis.com→mng.sam.kr
favicon CORS 차단 문제 해결.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-15 16:13:12 +09:00
parent 7a7bbe481a
commit 0521df47ca
2 changed files with 22 additions and 7 deletions

View File

@@ -185,19 +185,24 @@ public function download(int $id): BinaryFileResponse|RedirectResponse|JsonRespo
}
/**
* 영상 미리보기 (스트리밍)
* 영상 미리보기 (스트리밍 또는 서명URL)
*
* ?url=1 파라미터: JSON으로 서명URL 반환 (CORS 회피용)
* 그 외: 로컬 파일 직접 스트리밍
*/
public function preview(int $id): Response|RedirectResponse|JsonResponse
public function preview(Request $request, int $id): Response|RedirectResponse|JsonResponse
{
$tutorial = TutorialVideo::findOrFail($id);
if ($tutorial->gcs_path && $this->gcsService->isAvailable()) {
// ?url=1 → JSON으로 GCS 서명URL 반환 (video src에서 직접 사용)
if ($request->query('url') && $tutorial->gcs_path && $this->gcsService->isAvailable()) {
$signedUrl = $this->gcsService->getSignedUrl($tutorial->gcs_path, 60);
if ($signedUrl) {
return redirect()->away($signedUrl);
return response()->json(['url' => $signedUrl]);
}
}
// 로컬 파일 직접 스트리밍
if (! $tutorial->output_path || ! file_exists($tutorial->output_path)) {
return response()->json(['message' => '영상 파일을 찾을 수 없습니다.'], 404);
}