Skip to content

Commit 7e39fdd

Browse files
committed
fix: strip crossorigin from renderer HTML for file:// loads (white screen)
Vite injects crossorigin on script/link tags; under loadFile() + file:// Chromium treats these as CORS fetches without ACAO, so JS/CSS fail and #root stays empty. Release 0.2.6. Made-with: Cursor
1 parent 0ec3515 commit 7e39fdd

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

electron.vite.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
import { defineConfig } from 'electron-vite'
2+
import type { Plugin } from 'vite'
23
import react from '@vitejs/plugin-react'
34
import tailwindcss from '@tailwindcss/vite'
45
import path from 'path'
56
import { fileURLToPath } from 'url'
67

78
const __dirname = path.dirname(fileURLToPath(import.meta.url))
89

10+
/**
11+
* Vite injects `crossorigin` on injected script/link tags. With `loadFile()` the renderer uses
12+
* the `file://` protocol; Chromium treats module scripts/styles with `crossorigin` as CORS fetches,
13+
* which fail without ACAO headers — result is an empty #root (white screen). Strip for production HTML.
14+
*/
15+
function stripCrossoriginForFileProtocol(): Plugin {
16+
return {
17+
name: 'strip-crossorigin-file-protocol',
18+
enforce: 'post',
19+
transformIndexHtml: {
20+
order: 'post',
21+
handler(html: string) {
22+
return html.replace(/\s+crossorigin(?:=["'][^"']*["'])?/gi, '')
23+
},
24+
},
25+
}
26+
}
27+
928
export default defineConfig({
1029
main: {
1130
build: {
@@ -26,7 +45,7 @@ export default defineConfig({
2645
},
2746
renderer: {
2847
base: './',
29-
plugins: [react(), tailwindcss()],
48+
plugins: [react(), tailwindcss(), stripCrossoriginForFileProtocol()],
3049
resolve: {
3150
alias: {
3251
'@': path.resolve(__dirname, 'src/renderer'),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openclaw-desktop",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Community-maintained Windows desktop app and installer for OpenClaw.",
55
"type": "module",
66
"main": "out/main/index.js",

resources/bundle-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"shellVersion": "0.2.5",
2+
"shellVersion": "0.2.6",
33
"bundledOpenClawVersion": "2026.3.23-1"
44
}

0 commit comments

Comments
 (0)