规避请求方式的方法

发布时间:
更新时间:
🕒 阅读时间:1 min read 👀 阅读量:Loading...

vue-cli请求拦截器中添加以下代码

if (config.method === 'delete' || config.method === 'put' || config.method === 'option') {
config.headers['ORIGINAL_METHOD'] = config.method.toUpperCase();
config.method = 'POST'
}

Nginx请求中的配置

location /xxxx请求/{
# 还原原始请求方法
set $ori_method $request_method;
if ($http_ORIGINAL_METHOD != '') {
set $ori_method $http_ORIGINAL_METHOD;
}
proxy_method $ori_method;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8880;
}

规避请求方式的方法

作者: Mindspark

本文链接: https://oxai.net.cn/posts/b1e08af1

本文采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。

留言评论

2000年1月1日星期六
00:00:00