|
|
const express = require('express'); |
|
|
const puppeteer = require('puppeteer'); |
|
|
|
|
|
const app = express(); |
|
|
const targetUrl = 'https://chatgpt.com/'; |
|
|
|
|
|
app.get('/', async (req, res) => { |
|
|
const browser = await puppeteer.launch(); |
|
|
const page = await browser.newPage(); |
|
|
await page.goto(targetUrl); |
|
|
const html = await page.content(); |
|
|
await browser.close(); |
|
|
|
|
|
|
|
|
const newHtml = html.replace(new RegExp(targetUrl, 'g'), req.protocol + '://' + req.get('host')); |
|
|
|
|
|
res.send(newHtml); |
|
|
}); |
|
|
|
|
|
const port = 7860; |
|
|
app.listen(port, () => { |
|
|
console.log(`Сервер запущен на порту ${port}`); |
|
|
}); |