ninomae1001 commited on
Commit
828c20a
1 Parent(s): eb4525c

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +9 -6
server.js CHANGED
@@ -1,13 +1,16 @@
1
  const express = require('express');
2
- const proxy = require('express-http-proxy');
 
3
  const app = express();
4
- const targetUrl = 'https://api.openai.com'; // OpenAI API endpoint
5
- app.use('/hf/', proxy(targetUrl, {
6
- proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
7
- // Modify the request headers if necessary
8
- return proxyReqOpts;
 
9
  },
10
  }));
 
11
  const port = 7860;
12
  app.listen(port, () => {
13
  console.log(`Reverse proxy server listening on port ${port}`);
 
1
  const express = require('express');
2
+ const { createProxyMiddleware } = require('http-proxy-middleware');
3
+
4
  const app = express();
5
+
6
+ app.use('/proxy', createProxyMiddleware({
7
+ target: 'http://www.baidu.com',
8
+ changeOrigin: true,
9
+ pathRewrite: {
10
+ '^/proxy': '/',
11
  },
12
  }));
13
+
14
  const port = 7860;
15
  app.listen(port, () => {
16
  console.log(`Reverse proxy server listening on port ${port}`);