mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Load images the panel redirects to the app's server with CORS
The app treats those images as its own site's and loads them without CORS, so once they come from the app's server WebGL refuses them and Cesium stops rendering.
This commit is contained in:
1 parent
06460020d0
commit
5b555d7708
1 file changed
+10
-3
+10
-3
@@ -149,7 +149,12 @@ function panelHtml(appOrigin) {
|
||||
Object.defineProperty(type.prototype, attribute, {
|
||||
...property,
|
||||
set(value) {
|
||||
property.set.call(this, toApp(value));
|
||||
const target = toApp(value);
|
||||
// The app treated the address as its own site; now that it is
|
||||
// another site, images must load with CORS or WebGL refuses them.
|
||||
if (target !== value && 'crossOrigin' in this && this.crossOrigin === null)
|
||||
this.crossOrigin = 'anonymous';
|
||||
property.set.call(this, target);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -184,8 +189,10 @@ function panelHtml(appOrigin) {
|
||||
if (node.nodeType !== 1) continue;
|
||||
for (const element of [node, ...node.querySelectorAll('[src]')]) {
|
||||
const value = element.getAttribute('src');
|
||||
if (value && toApp(value) !== value)
|
||||
element.setAttribute('src', toApp(value));
|
||||
if (!value || toApp(value) === value) continue;
|
||||
if ('crossOrigin' in element && element.crossOrigin === null)
|
||||
element.crossOrigin = 'anonymous';
|
||||
element.setAttribute('src', toApp(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user