From 62bc57a9532e73a1df9c570e000b204b5afc5626 Mon Sep 17 00:00:00 2001 From: Max Gerber <89937743+max-stytch@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:27:37 -0700 Subject: [PATCH] fix: [AUTH-2047] disable fetch cache for all requests (#271) * fix: [AUTH-2047] disable fetch cache for all requests * 9.0.5 --- dist/shared/index.js | 1 + lib/shared/index.ts | 1 + package-lock.json | 2 +- package.json | 2 +- test/shared/shared.test.ts | 4 ++++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/shared/index.js b/dist/shared/index.js index 102f3f51..2655e950 100644 --- a/dist/shared/index.js +++ b/dist/shared/index.js @@ -16,6 +16,7 @@ async function request(fetchConfig, requestConfig) { response = await fetch(url.toString(), { method: requestConfig.method, body: body, + cache: "no-store", ...fetchConfig }); } catch (e) { diff --git a/lib/shared/index.ts b/lib/shared/index.ts index 4578e357..e356d973 100644 --- a/lib/shared/index.ts +++ b/lib/shared/index.ts @@ -36,6 +36,7 @@ export async function request<T>( response = await fetch(url.toString(), { method: requestConfig.method, body: body, + cache: "no-store", ...fetchConfig, }); } catch (e) { diff --git a/package-lock.json b/package-lock.json index a317132c..c2207d35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "stytch", - "version": "9.0.4", + "version": "9.0.5", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 49f6185b..66aae8a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stytch", - "version": "9.0.4", + "version": "9.0.5", "description": "A wrapper for the Stytch API", "types": "./types/lib/index.d.ts", "main": "./dist/index.js", diff --git a/test/shared/shared.test.ts b/test/shared/shared.test.ts index 963ae3d0..4479e094 100644 --- a/test/shared/shared.test.ts +++ b/test/shared/shared.test.ts @@ -28,6 +28,7 @@ describe("request", () => { expect(fetchMock).toHaveBeenCalledWith("http://localhost:8000/hello", { method: "GET", + cache: "no-store", ...MOCK_FETCH_CONFIG, }); }); @@ -37,6 +38,7 @@ describe("request", () => { await request(MOCK_FETCH_CONFIG, { url: "http://localhost:8000/hello", method: "GET", + cache: "no-store", params: { string: "here", number: 1234, @@ -47,6 +49,7 @@ describe("request", () => { expect(fetchMock).toHaveBeenCalledWith(expectedURL, { method: "GET", + cache: "no-store", ...MOCK_FETCH_CONFIG, }); }); @@ -67,6 +70,7 @@ describe("request", () => { expect(fetchMock).toHaveBeenCalledWith("http://localhost:8000/hello", { method: "GET", + cache: "no-store", body: `{"string":"here","number":1234,"deep":{"array":[123]}}`, ...MOCK_FETCH_CONFIG, });