File size: 611 Bytes
a302ca3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();

app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ extended: true, limit: '50mb' }));

app.use('hf/v1/chat/completions', createProxyMiddleware({
  target: 'http://localhost:3010',
  pathRewrite: {
    'hf/v1/chat/completions': 'v1/chat/completions', // 重写路径,将 /hf/v1/v2 替换为 /hf
  },
  changeOrigin: true,
}));

const port = process.env.HF_PORT || 7860;
app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);
});