}
const token = await getGoogleAuthToken(env.EMAIL, env.PRIVATE_KEY, 'https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/documents.readonly');
- const responsePromise = fetch(queryUrl, { headers: { Authorization: `Bearer ${token}` } });
+ const responsePromise = fetch(queryUrl, { headers: { Authorization: `Bearer ${token}` } })
+ .then(r => r.blob())
+ .then(b => new Response(b, { headers: { 'Content-Type': 'application/json' } })); // Remove extra response headers which may interfere with cache
const cachedResponse = await caches.default.match(queryUrl);
if (cachedResponse) {
waitUntil(responsePromise.then(response => caches.default.put(queryUrl, response)));