Update server.js
Browse files
server.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
-
const
|
| 3 |
-
|
| 4 |
const app = express();
|
| 5 |
-
const targetUrl = 'https://
|
| 6 |
-
|
| 7 |
-
app.get('/', async (req, res) => {
|
| 8 |
-
const browser = await puppeteer.launch();
|
| 9 |
-
const page = await browser.newPage();
|
| 10 |
-
await page.goto(targetUrl);
|
| 11 |
-
const html = await page.content();
|
| 12 |
-
await browser.close();
|
| 13 |
-
|
| 14 |
-
// Здесь вы можете модифицировать HTML-код, например, заменить URL-адреса
|
| 15 |
-
const newHtml = html.replace(new RegExp(targetUrl, 'g'), req.protocol + '://' + req.get('host'));
|
| 16 |
-
|
| 17 |
-
res.send(newHtml);
|
| 18 |
-
});
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
const port = 7860;
|
| 21 |
app.listen(port, () => {
|
| 22 |
-
console.log(
|
| 23 |
});
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
+
const proxy = require('express-http-proxy');
|
|
|
|
| 3 |
const app = express();
|
| 4 |
+
const targetUrl = 'https://chat.gpt.bz'; // OpenAI API endpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
app.use('/', proxy(targetUrl, {
|
| 7 |
+
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
| 8 |
+
return proxyReqOpts;
|
| 9 |
+
},
|
| 10 |
+
}));
|
| 11 |
const port = 7860;
|
| 12 |
app.listen(port, () => {
|
| 13 |
+
console.log(`Reverse proxy server listening on port ${port}`);
|
| 14 |
});
|