Skip to content

Commit

Permalink
update pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqlcom committed Oct 7, 2024
1 parent f15ee08 commit 07dfd46
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 109 deletions.
24 changes: 16 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ const target = process.env.TARGET || 'https://api.openai.com'
app.use('/', createProxyMiddleware({
target: target,
changeOrigin: true,
onProxyReq: (proxyReq, req, res) => {
proxyReq.removeHeader('x-forwarded-for');
proxyReq.removeHeader('x-real-ip');
},
onProxyRes: function (proxyRes, req, res) {
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
proxyRes.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
}
on: {
proxyReq: (proxyReq, req, res) => {
/* handle proxyReq */
proxyReq.removeHeader('x-forwarded-for');
proxyReq.removeHeader('x-real-ip');
},
proxyRes: (proxyRes, req, res) => {
/* handle proxyRes */
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
proxyRes.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
console.log(proxyRes)
},
error: (err, req, res) => {
/* handle error */
},
},
}));

app.listen(port, () => {
Expand Down
Loading

0 comments on commit 07dfd46

Please sign in to comment.