我正试图发布基于Messenger的第五款游戏Messenger Messenger,该游戏基于Canvas,并且包含Web Workers,URL:https://fb.gg/play/mballoons-instant
不幸的是,在Firefox中,出现以下错误:
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/storage.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/sizzle.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/dom.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/requestAnimationFrame.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/game.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/screen.splash.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/display.canvas.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/board.worker-interface.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/board.worker.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/audio.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/input.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/screen.highscore.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/screen.main-menu.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/screen.game.js (“object-src”).
Content Security Policy: The page’s settings blocked the loading of a resource at https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/images/balloons.png (“object-src”).
在我看来,问题出在以下文件https://apps-358163598249220.apps.fbsbx.com/instant-bundle/1811672228944054/2603592899715750/scripts/board.worker-interface.js?fbclid=IwAR0wHv196GjTXmK1yTw02-JHIrxiG2xl_YMmxpGMzZqkNaO7J9HVsGWijv4的worker = new Worker("scripts/board.worker.js")
行中
我尝试使用以下答案https://stackoverflow.com/a/33432215/11127383解决此问题,但无法弄清楚如何在我的案例中实现它。任何帮助将不胜感激,这是一个古老的游戏,但是只是想部署它。
如果您要下载所有游戏,则可能会在Chrome上运行index.html,
Uncaught DOMException: Failed to construct 'Worker': Script at '[FILE URI]' cannot be accessed from origin 'null'.
我知道这是因为它是从file:///
在本地计算机上运行的,而问题出在服务器上的应用程序一旦出现了,但是可能有任何提示。
尽管本地计算机上的Firefox(也使用file:///
)显示警告,但仍使游戏可以玩:
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it. storage.js
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.
...
对于Modernizr加载的所有文件。有趣的是,将其包装到Cordova时,我能够发布到Android,但在iOS上却没有。在iOS上,我遇到与Messenger相同的问题,游戏仅加载并且出现黑屏。在运行的控制台日志中,可以看到有关CSP的错误。