djangox-frame-options

Force setup X-Frame-Options Django


I tried different methods to setup X-Frame-Options to 'SAMEORIGIN' in the Django-server responses, but it wasn't help:

  1. I removed XFrame package from the middleware in settings.py.
  2. I putted X_FRAME_OPTIONS='SAMEORIGIN' to settings.py
  3. I added 'X-Frame-Options' to response object with the same value in my view in which I wanted to use the <iframe>
  4. I tried to add @xframe_options_sameorigin decorator to my view.
  5. I also changed /etc/apache2/apache2.conf, putted Header always set X-Frame-Options "SAMEORIGIN" into it.

Then I tried to restart apache2 service after all my actions but the result always the same:

X-Frame-Options setted as 'DENY'

My Django version is 2.2.4.


Solution

  • Sorry, some of this methods have worked. Update of browser page has not worked at first time, but after few minutes, it has worked. All done, thank you.