fix(desktop): strip crossorigin from built assets so macOS 12 webview loads#2883
Merged
Conversation
… loads Vite tags the entry module + stylesheet with crossorigin; over the wails:// scheme on Safari 15 WebKit (macOS <=12) the CORS fetch has no allow-origin and is blocked, so the bundle never runs and the window paints blank. Same-origin embedded assets need no CORS, so dropping the attribute restores rendering.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users on macOS 12.6 Intel report the downloaded desktop app launches to a black screen, while
wails dev/pnpm devruns fine on the same machine.Root cause
Vite emits the entry script and stylesheet with a
crossoriginattribute:http://127.0.0.1:5173(a normal http origin), so the CORS-mode fetch thecrossoriginattribute forces is satisfied.wails://scheme. On the older WebKit shipped with macOS ≤ 12 (Safari 15), thecrossoriginfetch over a custom scheme is treated as cross-origin and the scheme handler returns noAccess-Control-Allow-Origin, so the request is blocked — the bundle never runs and only the dark window background paints, which reads as a black screen. Ventura+ WebKit tolerates it, so it only reproduces on macOS ≤ 12.The window itself opens (hence a dark screen, not a crash or a Gatekeeper 'damaged' error), and the binary is universal + ad-hoc signed without hardened runtime, so architecture and JIT entitlements are not involved.
Fix
A tiny
transformIndexHtmlplugin strips thecrossoriginattribute from the builtindex.html. Wails serves everything same-origin, so CORS is not needed and the same-origin module/stylesheet load normally.Validation
tsc --noEmit+vite buildclean; builtindex.htmlno longer carriescrossorigin.