Search code examples
djangox-frame-options

How to set xframe options properly to display a pdf


So I get this error when trying to render a pdf in html with

Refused to display 'http://127.0.0.1:8000/' in a frame because it set 'X-Frame-Options' to 'deny'.

I already tried

  1. Setting X_FRAME_OPTIONS = 'SAMEORIGIN'
  2. Using @xframe_options_sameorigin as decorator to my view
  3. Removed the xframe package in the settings

nothing seems to work so I don't know what to do anymore.


Solution

  • So I did some more research and what worked for me was:

    Doing a hard reload from the webpage:

    This clears the cache which often causes issues in development https://www.sunilchauhan.com/learn/what-does-ctrl-shift-r-do-in-chrome/