Django nginx拒绝显示在一个框架中因为它将'X-Frame-Options'设置为'SAMEORIGIN'

时间:2023-01-10 13:47:35

I have deployed a django web application on a server with nginx and uwsgi. I can access the site perfectly using the ip address.

我在服务器上使用nginx和uwsgi部署了一个django Web应用程序。我可以使用IP地址完美访问该网站。

I purchased a domain name say abc.example.com and pointed it to my ip address. Now when i go the domain name it loads a blank page and throws an error in browser console:

我购买了一个域名abc.example.com并将其指向我的IP地址。现在,当我去域名时,它会加载一个空白页面并在浏览器控制台中抛出一个错误:

In Chrome:

在Chrome中:

Refused to display 'ip address' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

In Mozilla:

在Mozilla:

Load denied by X-Frame-Options: 'ip address' does not permit cross-origin framing.

The point is I dont have any iframe in my whole Application.

关键是我的整个应用程序中没有任何iframe。

What is this error and how can i solve it?

这是什么错误,我该如何解决?

When i go to application using ip address it works perfectly as it is supposed to be. Then what is the problem with domain? I double checked the settings in dns zone on godaddy but couldn't figure out anything.

当我使用ip地址进入应用程序时,它应该完美地工作。然后域名有什么问题?我仔细检查了godaddy的dns区域中的设置,但无法弄清楚任何事情。

1 个解决方案

#1


0  

In 'settings.py' file, add these two lines. It may help you.

在'settings.py'文件中,添加这两行。它可能会帮助你。

X_FRAME_OPTIONS = 'ALLOWALL'

XS_SHARING_ALLOWED_METHODS = ['POST','GET','OPTIONS', 'PUT', 'DELETE']

#1


0  

In 'settings.py' file, add these two lines. It may help you.

在'settings.py'文件中,添加这两行。它可能会帮助你。

X_FRAME_OPTIONS = 'ALLOWALL'

XS_SHARING_ALLOWED_METHODS = ['POST','GET','OPTIONS', 'PUT', 'DELETE']