From 24d655fd6fd8bd090f59d0898a15a49476c4b0cb Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 28 Jul 2026 15:03:22 +0200 Subject: [PATCH 1/3] New version. --- package.json | 2 +- src/renderer/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1e6d3076..e80bff9c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "url": "git+https://github.com/opencor/webapp.git" }, "type": "module", - "version": "0.20260728.0", + "version": "0.20260728.1", "engines": { "bun": ">=1.2.0" }, diff --git a/src/renderer/package.json b/src/renderer/package.json index e716cf73..abc8fa36 100644 --- a/src/renderer/package.json +++ b/src/renderer/package.json @@ -42,7 +42,7 @@ }, "./style.css": "./dist/opencor.css" }, - "version": "0.20260728.0", + "version": "0.20260728.1", "libopencorVersion": "1.20260723.2", "scripts": { "build": "vite build && bun scripts/generate.version.ts", From b98b699764d7563d58b7db34c4d0387bc29456a1 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 28 Jul 2026 15:43:46 +0200 Subject: [PATCH 2/3] Some minor improvements to src/renderer/README.md. --- src/renderer/README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/renderer/README.md b/src/renderer/README.md index 5fcedc35..40cdacbb 100644 --- a/src/renderer/README.md +++ b/src/renderer/README.md @@ -16,18 +16,20 @@ Key characteristics: ## Deployment -OpenCOR's Web app requires **cross-origin isolation** to use features like `SharedArrayBuffer` (needed by libOpenCOR). This is done by sending the following HTTP headers on the HTML page that loads the Web app: +### Cross-origin isolation + +OpenCOR's Web app relies on libOpenCOR's threaded WebAssembly (WASM) to run simulations in the browser. Threaded WASM requires [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), which in turn requires the page to be served with **cross-origin isolation** headers. + +When deploying OpenCOR's Web app, your Web server **must** send the following headers with the HTML document: ```http Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp ``` -Without these headers, the Web app will fail to initialise libOpenCOR and will not function. +Without these headers, OpenCOR's Web app will fail to initialise libOpenCOR and will not function. -### Server configuration - -The exact steps depend on your Web server. Here are the steps for Apache: +The exact steps to set these headers depend on your Web server. Here are the steps for Apache: 1. **Enable `mod_headers`**. Ensure the `headers` module is enabled (e.g., `a2enmod headers` or add it to your modules list). 2. **Set headers on the HTML path**. In your virtual host config, add: @@ -41,7 +43,7 @@ The exact steps depend on your Web server. Here are the steps for Apache: Adjust the `Location` path to match the URL prefix where the Web app is served (here, we use `/app` assuming the Web app is served from `https://your-domain.com/app`). 3. **Reload Apache**. Apply the changes with `sudo apachectl reload` or the equivalent for your distribution. -4. **Verify**. Check the response headers on your deployed HTML page (the trailing slash is important): +4. **Verify**. Check the response headers on your deployed HTML page using: ```bash curl -I https://your-domain.com/app/ @@ -54,7 +56,7 @@ The exact steps depend on your Web server. Here are the steps for Apache: cross-origin-embedder-policy: require-corp ``` -### Serving libOpenCOR downloads +### Serving libOpenCOR with cross-origin headers If you serve libOpenCOR (`.js` and `.wasm` files) from the same origin as the HTML page, then they are covered by the document's cross-origin isolation policy and require no additional headers. @@ -65,10 +67,13 @@ On the other hand, if you serve it from a different path on a different origin, Header set Access-Control-Allow-Origin "*" Header set Cross-Origin-Embedder-Policy "require-corp" + Header set Cross-Origin-Resource-Policy "cross-origin" ``` +With `Cross-Origin-Resource-Policy: cross-origin`, the resource can be fetched cross-origin, which is required for the page to load the library when served from a different origin. + ## Usage OpenCOR accepts the following props: From 534accf243e0f2363243832bbe96292e3a6da5a9 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 28 Jul 2026 16:22:55 +0200 Subject: [PATCH 3/3] Simplified the proxy configuration for WASM downloads. Removed the proxyRes header injection for Cross-Origin-Embedder-Policy from the WASM proxy configuration since the header is already set at the server level. Also removed the now-outdated comments referencing initialisation.ts. --- electron.vite.config.ts | 8 +------- src/renderer/vite.config.ts | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/electron.vite.config.ts b/electron.vite.config.ts index c32aae6c..21ed4b39 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -76,15 +76,9 @@ export default electronVite.defineConfig({ 'Cross-Origin-Embedder-Policy': 'require-corp' }, proxy: { - // See src/renderer/src/common/initialisation.ts for the rationale behind this proxy. '/libopencor/downloads/wasm': { target: 'https://opencor.ws', - changeOrigin: true, - configure: (proxy) => { - proxy.on('proxyRes', (proxyRes) => { - proxyRes.headers['Cross-Origin-Embedder-Policy'] = 'require-corp'; - }); - } + changeOrigin: true } } } diff --git a/src/renderer/vite.config.ts b/src/renderer/vite.config.ts index 85140cea..e62a8039 100644 --- a/src/renderer/vite.config.ts +++ b/src/renderer/vite.config.ts @@ -70,15 +70,9 @@ export default vite.defineConfig({ 'Cross-Origin-Embedder-Policy': 'require-corp' }, proxy: { - // See src/renderer/src/common/initialisation.ts for the rationale behind this proxy. '/libopencor/downloads/wasm': { target: 'https://opencor.ws', - changeOrigin: true, - configure: (proxy) => { - proxy.on('proxyRes', (proxyRes) => { - proxyRes.headers['Cross-Origin-Embedder-Policy'] = 'require-corp'; - }); - } + changeOrigin: true } } }