Skip to content

Commit

Permalink
hotfix cache upload image
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Jul 25, 2024
1 parent 00be2be commit ecd78b3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ self.addEventListener("install", function (event) {
);
});

function jsonify(data) {
return Response(JSON.stringify(data), { headers: { 'content-type': 'application/json' } })
}

async function upload(request, url) {
const formData = await request.formData()
const file = formData.getAll('file')[0]
Expand All @@ -33,13 +37,13 @@ async function upload(request, url) {
'server': 'ServiceWorker',
}
}))
return Response.json({ code: 0, data: fileUrl })
return jsonify({ code: 0, data: fileUrl })
}

async function remove(request, url) {
const cache = await caches.open(CHATGPT_NEXT_WEB_FILE_CACHE)
const res = await cache.delete(request.url)
return Response.json({ code: 0 })
return jsonify({ code: 0 })
}

self.addEventListener("fetch", (e) => {
Expand Down

0 comments on commit ecd78b3

Please sign in to comment.