Skip to content

Commit

Permalink
Use gstatic URL for canvaskit, to avoid CORS errors (#2965)
Browse files Browse the repository at this point in the history
* Use gstatic URL for canvaskit, to avoid CORS errors

* remove CORS header configuration
  • Loading branch information
johnpryan committed May 13, 2024
1 parent edcd12a commit 20da963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 0 additions & 9 deletions pkgs/dartpad_ui/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@
}
]
},
{
"source": "/canvaskit/chromium/canvaskit.wasm",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
},
{
"source": "**",
"headers": [
Expand Down
8 changes: 5 additions & 3 deletions pkgs/dartpad_ui/web/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ function messageHandler(e) {
var obj = e.data;

if (obj.command === 'execute') {
runFlutterApp(obj.js);
runFlutterApp(obj.js, obj.canvasKitBaseUrl);
}
};

function runFlutterApp(compiledScript) {
function runFlutterApp(compiledScript, canvasKitBaseUrl) {
var blob = new Blob([compiledScript], {type: 'text/javascript'});
var url = URL.createObjectURL(blob);
_flutter.loader.loadEntrypoint({
entrypointUrl: url,
onEntrypointLoaded: async function(engineInitializer) {
let appRunner = await engineInitializer.initializeEngine();
let appRunner = await engineInitializer.initializeEngine(
{canvasKitBaseUrl: canvasKitBaseUrl}
);
appRunner.runApp();
}
});
Expand Down

0 comments on commit 20da963

Please sign in to comment.