-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d9186b
commit 9597dd3
Showing
10 changed files
with
98 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @file A service worker that redirects paths without extensions to `/index.html`. | ||
* This is required for paths like `/login`, which are handled by client-side routing, | ||
* to work when developing locally on `localhost:8080`. */ | ||
// Bring globals and interfaces specific to Web Workers into scope. | ||
/// <reference lib="WebWorker" /> | ||
import * as common from 'enso-common' | ||
|
||
// ===================== | ||
// === Fetch handler === | ||
// ===================== | ||
|
||
// We `declare` a variable here because Service Workers have a different global scope. | ||
// eslint-disable-next-line no-restricted-syntax | ||
declare const self: ServiceWorkerGlobalScope | ||
|
||
self.addEventListener('fetch', event => { | ||
const url = new URL(event.request.url) | ||
if (url.hostname === 'localhost' && url.pathname !== '/esbuild') { | ||
event.respondWith( | ||
fetch(event.request.url).then(response => { | ||
const clonedResponse = new Response(response.body, response) | ||
for (const [header, value] of common.COOP_COEP_CORP_HEADERS) { | ||
clonedResponse.headers.set(header, value) | ||
} | ||
return clonedResponse | ||
}) | ||
) | ||
return | ||
} else { | ||
return false | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters