错误“您正在通过 HTTPS 访问开发服务器,但它仅支持 HTTP" [英] Error "You're accessing the development server over HTTPS, but it only supports HTTP"

查看:35
本文介绍了错误“您正在通过 HTTPS 访问开发服务器,但它仅支持 HTTP"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试编写服务器链接时,如 http://.... 它重定向到 https://并在终端中:

When I try to write the server link like http:// .... it redirects to https:// and in the terminal :

message Bad HTTP/0.9 request type ('x16x03x01x00x8bx01x00x00x87x03x01Ðx118¿JÄx19[Òçx01<O')
You're accessing the development server over HTTPS, but it only supports HTTP.

推荐答案

我认为你应该创建不同的 settings.py ( base_settings.py, local_settings.py, production_settings.py).在你的 settings.py 中做这样的事情:

I think you should create different settings.py ( base_settings.py, local_settings.py, production_settings.py). And in your settings.py do something like this:

import socket
if socket.gethostname()=="Raouf-PC":
    from local_settings import *

将Raouf-PC"更改为您电脑的主机名.

Change 'Raouf-PC' to the hostname of your PC.

P:S:我使用的是 Windows 10.

P:S: I'm using Windows 10.

完成后,将以下数据放入您的 production_settings.py 并保存.然后清除浏览器缓存并在开发服务器中访问您的站点.

After doing that place the below data in your production_settings.py and save. Then clear your browser cache and visit your site in development server.

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True

如果以上不适合您的需求,则在您的 local_settings.py 中粘贴以下数据,保存并清除浏览器缓存并访问您的网站.

If the above doesn't suit your needs, then in your local_settings.py paste the below data, save and clear your browser cache and visit your site.

SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False

注意:在production_setttings.py和local_settings.py的开头放:

Note: at the beginning of production_setttings.py and local_settings.py put:

from base_settings.py import *

您的基本设置应包含将在本地和生产服务器上使用的设置",这样您就不会每次都重复.

Your base settings should contain 'settings' that will be used both on local and production server so you won't be repeating it everytime.

P:S 如果我的回答被接受,我会将其献给 SO 上以某种方式帮助过我的好人.这是我第一次回答问题.我希望将来能做更多.:)

P:S If my answer is accepted, I dedicate it to the good people on SO who have helped me in one way or the other. This is my first time of answering a question. I hope to do more in the future. :)

这篇关于错误“您正在通过 HTTPS 访问开发服务器,但它仅支持 HTTP"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆