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',
 
原文地址:https://www.cnblogs.com/sumafan/p/10806964.html