Update server.js
Browse files
server.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
-
const
|
|
|
|
| 3 |
const app = express();
|
| 4 |
-
|
| 5 |
-
app.use('/
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 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}`);
|