报错:
newsDetailed:1 Access to XMLHttpRequest at 'http://www.py32api.com:8000/users/uploadFile/' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field token is not allowed by Access-Control-Allow-Headers in preflight response.
解决办法:
editor_instance = new WangEditor(editor.value);
// 查看这里设置的请求头
editor_instance.config.uploadImgHeaders = {
Token: getToken() // 设置请求头,通过Cookies 二次封装的getToken 函数获取
}
# 在django的setting.py里加上对应的
CORS_ALLOW_HEADERS = (
'token',
'...',
)
标签:Vue,http,跨域,Access,instance,报错,editor From: https://www.cnblogs.com/vPYer/p/17920690.html