Skip to content

Commit daf6eff

Browse files
committed
Revert "Supports local execution via npx"
This reverts commit d79748a.
1 parent d79748a commit daf6eff

File tree

7 files changed

+351
-418
lines changed

7 files changed

+351
-418
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ ENV NODE_ENV=production
2929
# copy production dependencies and source code into final image
3030
FROM base AS release
3131
COPY --from=install /temp/prod/node_modules node_modules
32-
COPY --from=prerelease /usr/src/app .
32+
COPY --from=prerelease /usr/src/app/app.js .
33+
COPY --from=prerelease /usr/src/app/package.json .
3334

3435
# run the app
3536
USER bun

app.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
const createProxyApp = require('./core');
2-
const { defaultPort, defaultTarget } = require('./config');
1+
const express = require('express')
2+
const { createProxyMiddleware } = require('http-proxy-middleware');
3+
const app = express()
4+
const port = process.env.PORT || 9017
5+
const target = process.env.TARGET || 'https://api.openai.com'
36

4-
const port = process.env.PORT || defaultPort;
5-
const target = process.env.TARGET || defaultTarget;
6-
7-
const app = createProxyApp(target);
7+
app.use('/', createProxyMiddleware({
8+
target: target,
9+
changeOrigin: true,
10+
on: {
11+
proxyReq: (proxyReq, req, res) => {
12+
/* handle proxyReq */
13+
proxyReq.removeHeader('x-forwarded-for');
14+
proxyReq.removeHeader('x-real-ip');
15+
},
16+
proxyRes: (proxyRes, req, res) => {
17+
/* handle proxyRes */
18+
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
19+
proxyRes.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
20+
},
21+
error: (err, req, res) => {
22+
/* handle error */
23+
},
24+
},
25+
}));
826

927
app.listen(port, () => {
10-
console.log(`Proxy agent started: http://localhost:${port}`);
11-
console.log(`Target: ${target}`);
12-
});
28+
console.log(`Proxy agent started: http://localhost:${port}`)
29+
})

cli.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

core.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)