gpt4 book ai didi

django - 如何从本地主机(http)向django(https)发送POST请求?

转载 作者:可可西里 更新时间:2023-11-01 16:35:58 25 4
gpt4 key购买 nike

将所有参数(header/cookie/post)作为docs发送到代理/api

PrtScreen with request param (header/cookie/post)

得到

PrtScreen with response 403 Forbidden

server.js

'use strict';

const fs = require('fs'),
proxy = require('http-proxy-middleware'),
browserSync = require('browser-sync').create();

function returnIndexPageFn(req, res, next) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(fs.readFileSync('./public/app.html'));
res.end();
next();
}

browserSync.init({
port: 88,
server: {
baseDir: 'public/',
index: 'app.html',
middleware: [
{route: '/home', handle: returnIndexPageFn},
proxy(['/api', '/media'], {
target: 'https://security-site.com',
logLevel: 'debug',
changeOrigin: true,
headers: {
Referer: 'https://security-site.com',
},
})
]
}
});

我尝试另一个角度为 5 的,但结果相同(((

proxy.conf.json

{
"/api": {
"target": "https://security-site.com/",
"secure": false,
"changeOrigin": true,
"logLevel": "info"
}
}

如何解决这个问题?

最佳答案

我找到了解决方案:

需要将标题 Referal 更改为 https 协议(protocol)

对于 browser-sync

server.js

...
proxy(['/api', '/media'], {
target: 'https://security-site.com',
logLevel: 'debug',
changeOrigin: true,
headers: {
Referer: 'https://security-site.com',
},
})
...

对于角度 5(角度 cli):proxy.conf.json

{
"/api": {
"target": "https://security-site.com/",
"headers": {
"Referer": "https://security-site.com/"
},
"secure": false,
"changeOrigin": true,
"logLevel": "info"
}
}

关于django - 如何从本地主机(http)向django(https)发送POST请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49319640/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com