我构建了一个使用Django API REST端点的Ionic 4应用程序。
该应用程序已经在iPad和我的本地主机上使用ionic- app -scripts serve进行了测试。
现在我想把它部署成一个webapp,我正在为浏览器平台构建(ionic cordova build browser --prod --release),并在运行了API REST的同一个Django App上为index.html提供服务。静态文件(js、资产等托管在亚马逊S3存储桶中)
现在,无论是在iPad上还是在本地主机上,API REST POST请求都没有问题。但是当我在实时服务器上运行应用程序时(即使请求来自与API REST相同的服务器!!)我得到403...
当我比较请求头部时,我看到的唯一区别是在直播服务器上发送的请求没有"Origin“参数:
在实时服务器上:
Accept application/json, text/plain, */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control no-cache
Connection keep-alive
Content-Length 62
content-type application/json
Cookie _ga=GA1.2.1002502516.149305462…eay6lysy1w44vawa94lug20hpek2n
Host example.com
Pragma no-cache
Referer http://example.com/front/
User-Agent Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/60.0在LOCALHOST上:
Accept application/json, text/plain, */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Connection keep-alive
Content-Length 62
content-type application/json
Host example.com
Origin http://localhost:8100
Referer http://localhost:8100/
User-Agent Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/60.0有什么想法吗?我知道有几个关于这个主题的问题和帖子,但通常问题是相反的(从另一个域发送帖子时会出现CORS问题)
(很明显,example.com不是我使用的真正的域名)
发布于 2018-06-29 03:37:02
我发现了问题,我有一个Django认证系统,我用它登录了。当我注销时,它工作正常。它似乎正在发送csrf令牌和请求上的cookies,这导致了冲突。
https://stackoverflow.com/questions/51089072
复制相似问题