成功的OPTIONS请求后POST失败

时间:2019-08-27 18:08:37

标签: axios django-cors-headers

我有一个带有cookie的POST请求。选项请求成功,但是post返回Internal Server Error并寻找进一步的超时。 选项:

Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: accept, accept-encoding, authorization, content-type, dnt, origin, user-agent, x-csrftoken, x-requested-with
Access-Control-Allow-Methods: DELETE, GET, OPTIONS, PATCH, POST, PUT
Access-Control-Allow-Origin: http://localhost:3001
Access-Control-Max-Age: 86400
Content-Length: 0
Content-Type: text/html; charset=utf-8
Vary: Origin
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST
Connection: keep-alive
Host: localhost:8000
Origin: http://localhost:3001
Referer: http://localhost:3001/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 OPR/62.0.3331.116

然后执行POST:

Provisional headers are shown
Content-Type: application/json;charset=UTF-8
Origin: http://localhost:3001
Referer: http://localhost:3001/
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 OPR/62.0.3331.116

我已设置withCredentials:true和CORS设置

CORS_ORIGIN_REGEX_WHITELIST = [
    '^http://localhost:3001$'
]
CORS_URLS_REGEX = r'^/domain/.*$'
CORS_ALLOW_CREDENTIALS = True

有什么想法吗? 谢谢

0 个答案:

没有答案