fixed fuckup with onupgrade promise needing to resolve
This commit is contained in:
parent
102f493a24
commit
403119f511
1 changed files with 3 additions and 4 deletions
|
@ -20,7 +20,7 @@ self.addEventListener("fetch", event =>{
|
||||||
})
|
})
|
||||||
|
|
||||||
async function handle_redirect(req){
|
async function handle_redirect(req){
|
||||||
const go_back_to = req.referrer;
|
const go_back_to = req.headers.get('Referer') || '/';;
|
||||||
const db_req = self.indexedDB.open("light-dark-store");
|
const db_req = self.indexedDB.open("light-dark-store");
|
||||||
const up_promise = new Promise((res)=>{
|
const up_promise = new Promise((res)=>{
|
||||||
db_req.onupgradeneeded = (event) => {
|
db_req.onupgradeneeded = (event) => {
|
||||||
|
@ -40,12 +40,11 @@ async function handle_redirect(req){
|
||||||
.then(res);
|
.then(res);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
await Promise.all([up_promise, suc_promise]);
|
await suc_promise;
|
||||||
const referrer = request.headers.get('Referer') || '/';
|
|
||||||
return new Response("You should be getting redirected back to the page you came from shortly",{
|
return new Response("You should be getting redirected back to the page you came from shortly",{
|
||||||
status: 302,
|
status: 302,
|
||||||
headers: {
|
headers: {
|
||||||
'Location': referrer
|
'Location': go_back_to
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue