0

I've read up about this error but the proposed solutions don't seem to work for .doc/.docx files.

I am building a web app which involves displaying pdf/doc files. The files are stored in a google storage bucket, and I am using Firebase's getDownloadURL() method to get a link which I can use as the source in an <iframe>. This works fine for PDF files directly. However, given that this direct display is not possible for doc/docx files, I tried displaying them through Google Docs Viewer by taking the generated URL and appending as follows:

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

This yields a Refused to display <URL> in a frame because it set X-Frame-Options to same origin error. I have also tried adding an &embedded=true to the URL as has been suggested in other similar queries, but that yields another error: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. I thought this could be an issue with parsing the URL due to the "&", so I changed it to "%26", but the "sameorigin" error persists.

I'm not sure how to tackle this, and any guidance on how to resolve this issue (or alternative ways of solving the problem) would be greatly appreciated.

  • Hello Patrice99, did you solve this issue. I have the same need and facing the same error. I have even set the CORS in google storage to allow *. Thanks – RmR Aug 01 '20 at 11:12
  • I got it working using the solution from this post: https://stackoverflow.com/questions/56388987/how-to-display-a-pdf-document-within-an-iframe-by-google-docs-viewer-stored-in-f – RmR Aug 01 '20 at 11:33

1 Answers1

0

Google docs creates its own storage objects, and will only serve those objects. It won't display other objects that happen to be in doc/docx format from other repositories.

It sounds like you need a way to render objects you uploaded (using Firebase) to GCS. I don't have experience doing that specific thing but I suggest you try to find some software that does it. For example from a quick web search I found Render docx file in a browser.

Mike Schwartz
  • 11,511
  • 1
  • 33
  • 36
  • The links in that answer are a bit outdated/broken, and almost all other solutions I've searched use google docs viewer (or the microsoft equivalent). Software that converts docx to HTML (for example) aren't what I'm looking for, for my use case, so I need a solution that works within this context. – patrice99 Jun 20 '20 at 00:06