Update index.js
Browse files
index.js
CHANGED
|
@@ -85,6 +85,53 @@ app.get('/proxy', async (req, res) => {
|
|
| 85 |
}
|
| 86 |
});
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
app.all('/imagetopdf', async (req, res) => {
|
| 89 |
if (!['POST'].includes(req.method)) return res.status(405).json({ success: false, message: 'Method Not Allowed' })
|
| 90 |
|
|
|
|
| 85 |
}
|
| 86 |
});
|
| 87 |
|
| 88 |
+
app.get('/pages', async (req, res) => {
|
| 89 |
+
const targetUrl = req.query.url;
|
| 90 |
+
|
| 91 |
+
if (!targetUrl) {
|
| 92 |
+
return res.status(400).json({ error: 'Parameter "url" dibutuhkan' });
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
const browser = await playwright.chromium.launch({
|
| 96 |
+
headless: true,
|
| 97 |
+
executablePath: '/usr/bin/chromium', // pastikan path ini benar di server kamu
|
| 98 |
+
args: ['--no-sandbox']
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
const context = await browser.newContext({
|
| 102 |
+
extraHTTPHeaders: {
|
| 103 |
+
'accept': '*/*',
|
| 104 |
+
'accept-language': 'en-US,en;q=0.9,id;q=0.8',
|
| 105 |
+
'cache-control': 'no-cache',
|
| 106 |
+
'origin': 'https://doujindesu.tv',
|
| 107 |
+
'pragma': 'no-cache',
|
| 108 |
+
'referer': 'https://doujindesu.tv',
|
| 109 |
+
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
| 110 |
+
'sec-ch-ua-mobile': '?0',
|
| 111 |
+
'sec-ch-ua-platform': '"Windows"',
|
| 112 |
+
'sec-fetch-dest': 'script',
|
| 113 |
+
'sec-fetch-mode': 'cors',
|
| 114 |
+
'sec-fetch-site': 'cross-site',
|
| 115 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
|
| 116 |
+
}
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
try {
|
| 120 |
+
const page = await context.newPage();
|
| 121 |
+
await page.goto(targetUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
| 122 |
+
|
| 123 |
+
// Tunggu ekstra jika perlu ngelewatin challenge
|
| 124 |
+
await page.waitForTimeout(8000);
|
| 125 |
+
|
| 126 |
+
const content = await page.content();
|
| 127 |
+
res.send(content);
|
| 128 |
+
} catch (err) {
|
| 129 |
+
res.status(500).json({ error: 'Gagal fetch halaman', detail: err.message });
|
| 130 |
+
} finally {
|
| 131 |
+
await browser.close();
|
| 132 |
+
}
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
app.all('/imagetopdf', async (req, res) => {
|
| 136 |
if (!['POST'].includes(req.method)) return res.status(405).json({ success: false, message: 'Method Not Allowed' })
|
| 137 |
|