From 9eb3c8f378ba9119934e41e5e2eb9ed963d0600e Mon Sep 17 00:00:00 2001 From: Jason <59297610+caracal-js@users.noreply.github.com> Date: Thu, 24 Feb 2022 14:50:39 -0500 Subject: [PATCH] E --- uv.bundle.js | 1 - uv.sw.js | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/uv.bundle.js b/uv.bundle.js index 781fe0a..00e786c 100644 --- a/uv.bundle.js +++ b/uv.bundle.js @@ -43,7 +43,6 @@ class HTML extends _events_js__WEBPACK_IMPORTED_MODULE_0__["default"] { this.iterate(ast, fn, options); return (0,parse5__WEBPACK_IMPORTED_MODULE_1__.serialize)(ast); } catch(e) { - console.log(e); return str; }; }; diff --git a/uv.sw.js b/uv.sw.js index 6a68596..1ba34a4 100644 --- a/uv.sw.js +++ b/uv.sw.js @@ -75,17 +75,19 @@ addEventListener('install', () => { }); -function UVServiceWorker(bare = '/bare/', options) { +function UVServiceWorker(_bare = '/bare/', options) { try { return async function handler(event) { const { request } = event; + const bare = new URL(_bare, location.href); + try { if (!request.url.startsWith(location.origin + (options.prefix || '/service/'))) { return fetch(request); }; const requestCtx = { - url: bare + 'v1/', + url: bare.href + 'v1/', referrer: false, headers: {}, forward: headers.forward, @@ -149,7 +151,7 @@ function UVServiceWorker(bare = '/bare/', options) { headers: !requestCtx.blob ? bareHeaders : requestCtx.headers, redirect: requestCtx.redirect, credentials: requestCtx.credentials, - mode: requestCtx.mode, + mode: location.origin !== bare.origin ? 'cors' : requestCtx.mode, }; if (requestCtx.body) fetchOptions.body = requestCtx.body;