Ai
1 Star 0 Fork 0

Aleyn/openai-scf-proxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 688 Bytes
一键复制 编辑 原始数据 按行查看 历史
Aleyn 提交于 2023-11-08 14:31 +08:00 . init
const express = require('express')
const {
createProxyMiddleware
} = require('http-proxy-middleware');
const app = express()
const port = 9000
app.use('/', createProxyMiddleware({
target: 'https://api.openai.com',
changeOrigin: true,
onProxyReq: (proxyReq, req, res) => {
// 移除 'x-forwarded-for' 和 'x-real-ip' 头,以确保不传递原始客户端 IP 地址等信息
proxyReq.removeHeader('x-forwarded-for');
proxyReq.removeHeader('x-real-ip');
},
onProxyRes: function (proxyRes, req, res) {
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
}
}));
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/MuAMuLin/openai-scf-proxy.git
git@gitee.com:MuAMuLin/openai-scf-proxy.git
MuAMuLin
openai-scf-proxy
openai-scf-proxy
master

搜索帮助