Fix borked guest token caching in workers runtime

This commit is contained in:
dangered wolf 2022-08-18 11:11:16 -04:00
parent c2a617d804
commit 01b3b8d79b
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -150,8 +150,14 @@ export const fetchUsingGuest = async (
} }
/* If we've generated a new token, we'll cache it */ /* If we've generated a new token, we'll cache it */
if (event && newTokenGenerated) { if (event && newTokenGenerated) {
const cachingResponse = new Response(await activate.clone().text(), {
headers: {
...tokenHeaders,
'cache-control': 'max-age=300'
}
});
console.log('Caching guest token'); console.log('Caching guest token');
event.waitUntil(cache.put(guestTokenRequestCacheDummy, activate.clone())); event.waitUntil(cache.put(guestTokenRequestCacheDummy, cachingResponse));
} }
conversation.guestToken = guestToken; conversation.guestToken = guestToken;
return conversation; return conversation;