From 01b3b8d79b65750f0571c9725de1bcf391d28554 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 18 Aug 2022 11:11:16 -0400 Subject: [PATCH] Fix borked guest token caching in workers runtime --- src/fetch.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index 73d14bf..ecd8385 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -150,8 +150,14 @@ export const fetchUsingGuest = async ( } /* If we've generated a new token, we'll cache it */ if (event && newTokenGenerated) { + const cachingResponse = new Response(await activate.clone().text(), { + headers: { + ...tokenHeaders, + 'cache-control': 'max-age=300' + } + }); console.log('Caching guest token'); - event.waitUntil(cache.put(guestTokenRequestCacheDummy, activate.clone())); + event.waitUntil(cache.put(guestTokenRequestCacheDummy, cachingResponse)); } conversation.guestToken = guestToken; return conversation;