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的主要内容,如果未能解决你的问题,请参考以下文章

跨域请求Access to XMLHttpRequest at 'http://localhost/index.php/api/user/login'

Access to XMLHttpRequest at ‘http://localhost:8181/book/findAll‘ from origin ‘http://localhost:8080‘

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

Access to XMLHttpRequest at 'XXX' from origin 'XX' has been blocked by CORS policy:

ElementUI项目请求SpringBoot后台项目时提示:Access to XMLHttpRequest at **from origin ** has been blocked by CORS

解决跨域Access to XMLHttpRequest at ‘http://localhost:8080/xxx’ from origin ‘http://localhost:63342