appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.32k stars 3.72k forks source link

[Bug]: [Document Viewer] Unable to view pdf files served via ngrok and pythonanywhere #26012

Open narhzih opened 1 year ago

narhzih commented 1 year ago

Is there an existing issue for this?

Description

I'm using Appsmith on Web so I have a local API exposed via ngrok. PDF Files served through this API can't be viewed using the Document Viewer widget. It throws an error refused to Connect error. When I tried it on PythonAnywhere, it didn't throw any error but isn't displaying anything. Other files like docx, jpg, and png from the same server worked, only pdf files aren't showing up for some reason.

Steps To Reproduce

  1. Create a local API that serves a PDF file.
  2. Expose this file via ngrok or Pythonanywhere
  3. Try to display the file using the Document Viewer widget

Public Sample App

No response

Environment

Production

Issue video log

No response

Version

Cloud version

berzerkeer commented 1 year ago

I tried creating a new api server which serves pdf file and used it with ngrok and it works fine for me. But the pythonanywhere URL by the user did indeed refused to connect and refused to display the content on the Document Viewer widget. So it seems like browser have certain restrictions handling contents and loading contents on an iframe, and there seems to be two issues here , the first error I am getting is

  1. The resource being mixed content ( we have a https page which fetches a http content )
  2. Also what I noticed is the pdf file server have the X-FRAME-OPTIONS : DENY header set which prevents the clients from loading the content. I don't find this header set to the pdf file I served via my ngrok api ( https://2bb1-122-178-195-194.ngrok-free.app/dummy.pdf )

Can we ask the user check if the server is setting this header and also they can connect to my ngrok api ad check, If that works, the issue is probably with the user's server configuration.

cc: @dilippitchika