cfiles icon indicating copy to clipboard operation
cfiles copied to clipboard

Absolute url / Relative url

Open Gilbertdelyon opened this issue 2 years ago • 2 comments

In our site we often use Iframes (custom pages) to display the content of some files (example: tutorial.pdf files ) Files and custom pages are of course stored in the same site. They are displayed correctly in FFox and Edge, but since a few days they are not displayed correctly in Chrome. Instead we get an error in the console: Refused to display '[https:/sitedomain.xy/](https://https/)' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

We dont understand the reason because everything is in the same site.

After some investigation we noticed the following:

  • In Iframe we used the absolute url ( easy and lazzy copy of the url that we get from the "Display Url" popup) . https://sitedomain.xy/HH/index.php?r=file%2Ffile%2Fdownload&guid=db4b25e2-57d6-4b69-b811-0a4f9b19a68b
  • should we use instead the relative url
    /HH/index.php?r=file%2Ffile%2Fdownload&guid=db4b25e2-57d6-4b69-b811-0a4f9b19a68b

Gilbertdelyon avatar Jan 11 '23 23:01 Gilbertdelyon

Hmm, thats strange. An option could be to allow the X-Frame-Options. https://docs.humhub.org/docs/admin/security#web-security-configuration

luke- avatar Jan 12 '23 17:01 luke-

Thanks Luke, No succes with your advice But it still works in FFox and Edge In Chrome it works only if we use relative url. And in Chrome/Android it doesn't work at all, but this is another story.

So, I built a "PDF Iframe" custom page template with a few lines of javascript that converts the native absolute url into a relative url.

Gilbertdelyon avatar Jan 12 '23 21:01 Gilbertdelyon