diff --git a/backend/src/common/revalidation/revalidation.service.spec.ts b/backend/src/common/revalidation/revalidation.service.spec.ts index 0004becc..645ea83e 100644 --- a/backend/src/common/revalidation/revalidation.service.spec.ts +++ b/backend/src/common/revalidation/revalidation.service.spec.ts @@ -26,6 +26,16 @@ describe("RevalidationService", () => { expect(service).toBeDefined(); }); + it("uses the Next server rather than the nginx API proxy as production fallback", async () => { + delete process.env.FRONTEND_INTERNAL_URL; + delete process.env.FRONTEND_URL; + delete process.env.NEXT_PUBLIC_SITE_URL; + process.env.NODE_ENV = "production"; + const fetchSpy = jest.spyOn(global, "fetch").mockResolvedValue({ ok: true } as Response); + await service.revalidate(["blogs"], ["/blog"]); + expect(fetchSpy).toHaveBeenCalledWith("http://frontend_prod:3000/api/revalidate", expect.anything()); + }); + describe("revalidateTag", () => { it("should send POST request with tag and secret header and return true on 200", async () => { const mockFetch = jest.spyOn(global, "fetch" as any).mockResolvedValue({ diff --git a/backend/src/common/revalidation/revalidation.service.ts b/backend/src/common/revalidation/revalidation.service.ts index e7e07f16..e9560841 100644 --- a/backend/src/common/revalidation/revalidation.service.ts +++ b/backend/src/common/revalidation/revalidation.service.ts @@ -10,7 +10,7 @@ export class RevalidationService { process.env.FRONTEND_URL || process.env.NEXT_PUBLIC_SITE_URL || (process.env.NODE_ENV === "production" - ? "http://frontend_prod:8080" + ? "http://frontend_prod:3000" : "http://localhost:3000"); return raw.replace(/\/+$/, ""); }