mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-16 04:50:01 -04:00
E
This commit is contained in:
parent
64a7599336
commit
fd8064a6d9
14 changed files with 5 additions and 1531 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue