【发布时间】:2020-10-10 01:41:08
【问题描述】:
我已阅读有关此错误的信息,但建议的解决方案似乎不适用于 .doc/.docx 文件。
我正在构建一个涉及显示 pdf/doc 文件的网络应用程序。这些文件存储在谷歌存储桶中,我正在使用 Firebase 的getDownloadURL() 方法获取一个链接,我可以将其用作<iframe> 中的源。这直接适用于 PDF 文件。但是,鉴于 doc/docx 文件无法直接显示,我尝试通过 Google Docs Viewer 显示它们,方法是获取生成的 URL 并附加如下:
https://docs.google.com/gview?url=https://firebasestorage.googleapis.com/v0/b/project-name.appspot.com/o/filename?alt=media&token=a-b-c-1-2-3
这会产生Refused to display <URL> in a frame because it set X-Frame-Options to same origin 错误。我也尝试过adding 和&embedded=true 到URL,正如其他类似查询中所建议的那样,但这会产生另一个错误:Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
由于“&”,我认为这可能是issue with parsing the URL,所以我将其更改为“%26”,但“sameorigin”错误仍然存在。
我不知道如何解决这个问题,如果有任何关于如何解决这个问题(或解决问题的替代方法)的指导,我将不胜感激。
【问题讨论】:
-
您好 Patrice99,您解决了这个问题吗?我有同样的需求并面临同样的错误。我什至在谷歌存储中设置了 CORS 以允许 *.谢谢
-
我使用这篇文章中的解决方案让它工作了:stackoverflow.com/questions/56388987/…
标签: html firebase google-cloud-storage same-origin-policy x-frame-options