Access to XMLHttpRequest at 'http://127.0.0.1:8000/XXXXX' from origin 'http://localhost

Posted sumafan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Access to XMLHttpRequest at 'http://127.0.0.1:8000/XXXXX' from origin 'http://localhost相关的知识,希望对你有一定的参考价值。

Django 报错,跨域请求出现问题。

在settings.py中添加

技术图片

#设置可跨域范围

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
技术图片
#定义跨域中间件
‘corsheaders.middleware.CorsMiddleware‘,
 

以上是关于Access to XMLHttpRequest at 'http://127.0.0.1:8000/XXXXX' from origin 'http://localhost的主要内容,如果未能解决你的问题,请参考以下文章