From 6a2abf115f68a1a86f7283250e2bfad6243a95b3 Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Tue, 20 Jan 2026 21:27:49 +0100 Subject: [PATCH] fix(s3): update public URL to include `path` query parameter - Updated `getPublicUrl` to use `?path=` format in public URLs. - Adjusted corresponding test cases to reflect the new URL structure. --- backend/src/s3/s3.service.spec.ts | 6 +++--- backend/src/s3/s3.service.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/s3/s3.service.spec.ts b/backend/src/s3/s3.service.spec.ts index be3281f..4965498 100644 --- a/backend/src/s3/s3.service.spec.ts +++ b/backend/src/s3/s3.service.spec.ts @@ -192,7 +192,7 @@ describe("S3Service", () => { return null; }); const url = service.getPublicUrl("test.webp"); - expect(url).toBe("https://api.test.com/media/test.webp"); + expect(url).toBe("https://api.test.com/media?path=test.webp"); }); it("should use DOMAIN_NAME and PORT for localhost", () => { @@ -205,7 +205,7 @@ describe("S3Service", () => { }, ); const url = service.getPublicUrl("test.webp"); - expect(url).toBe("http://localhost:3000/media/test.webp"); + expect(url).toBe("http://localhost:3000/media?path=test.webp"); }); it("should use api.DOMAIN_NAME for production", () => { @@ -217,7 +217,7 @@ describe("S3Service", () => { }, ); const url = service.getPublicUrl("test.webp"); - expect(url).toBe("https://api.memegoat.fr/media/test.webp"); + expect(url).toBe("https://api.memegoat.fr/media?path=test.webp"); }); }); }); diff --git a/backend/src/s3/s3.service.ts b/backend/src/s3/s3.service.ts index 0efa784..ab40bd0 100644 --- a/backend/src/s3/s3.service.ts +++ b/backend/src/s3/s3.service.ts @@ -173,6 +173,6 @@ export class S3Service implements OnModuleInit, IStorageService { baseUrl = `https://api.${domain}`; } - return `${baseUrl}/media/${storageKey}`; + return `${baseUrl}/media?path=${storageKey}`; } }