diff --git a/ProjectHeads/SingleComponent/Wasm/wwwroot/SharedArrayBufferServiceWorker.js b/ProjectHeads/SingleComponent/Wasm/wwwroot/SharedArrayBufferServiceWorker.js new file mode 100644 index 00000000..d8f6b3c2 --- /dev/null +++ b/ProjectHeads/SingleComponent/Wasm/wwwroot/SharedArrayBufferServiceWorker.js @@ -0,0 +1,39 @@ +// From https://dev.to/stefnotch/enabling-coop-coep-without-touching-the-server-2d3n + +self.addEventListener("install", function () { + self.skipWaiting(); +}); + +self.addEventListener("activate", (event) => { + event.waitUntil(self.clients.claim()); +}); + +self.addEventListener("fetch", function (event) { + if (event.request.cache === "only-if-cached" && event.request.mode !== "same-origin") { + return; + } + + event.respondWith( + fetch(event.request) + .then(function (response) { + // It seems like we only need to set the headers for index.html + // If you want to be on the safe side, comment this out + // if (!response.url.includes("index.html")) return response; + + const newHeaders = new Headers(response.headers); + newHeaders.set("Cross-Origin-Embedder-Policy", "credentialless"); + newHeaders.set("Cross-Origin-Opener-Policy", "same-origin"); + + const moddedResponse = new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: newHeaders, + }); + + return moddedResponse; + }) + .catch(function (e) { + console.error(e); + }) + ); +}); diff --git a/ProjectHeads/SingleComponent/Wasm/wwwroot/index.html b/ProjectHeads/SingleComponent/Wasm/wwwroot/index.html new file mode 100644 index 00000000..095835f0 --- /dev/null +++ b/ProjectHeads/SingleComponent/Wasm/wwwroot/index.html @@ -0,0 +1,38 @@ + + + +
+ + + + + + + + + $(ADDITIONAL_CSS) + $(ADDITIONAL_HEAD) + + +