Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gstatic URL for canvaskit, to avoid CORS errors #2965

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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