github托管代码axios post请求405怎么解决?

您所在的位置:网站首页 怎么打开homepage github托管代码axios post请求405怎么解决?

github托管代码axios post请求405怎么解决?

2023-06-18 12:21| 来源: 网络整理| 查看: 265

本地打包出来的代码,扔到Apache下运行的时候是正常的,所有请求都能正确处理。

axios.defaults.headers.post.Accept = 'application/json, text/javascript, */*; q=0.01'; axios.defaults.headers.post['X-Requested-With'] = 'xmlhttprequest'; axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; axios.interceptors.request.use((config) => { config.data = qs.stringify(config.data, {arrayFormat: 'brackets'}); return config; });

axios也已经做了配置。但是提交到github,开启homepage访问的时候,get请求正常,post请求405报错了。本地代码的请求头如下:

Accept: application/json, text/javascript, */*; q=0.01 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Connection: keep-alive Content-Length: 38 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Host: test.com Origin: http://test.com Referer: http://test.com/vue-ts/cart User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 X-Requested-With: xmlhttprequest

github上面的请求头如下:

:authority: no2015.github.io :method: POST :path: /vue-ts/static/api/updateCart.json :scheme: https accept: application/json, text/javascript, */*; q=0.01 accept-encoding: gzip, deflate, br accept-language: zh-CN,zh;q=0.9 content-length: 94 content-type: application/x-www-form-urlencoded; charset=UTF-8 origin: https://no2015.github.io referer: https://no2015.github.io/vue-ts/cart user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 x-requested-with: xmlhttprequest

是不是缺少了什么配置?还是github禁止了我的post请求?



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3