feat: add proxy server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { firefox } from "npm:playwright-extra";
|
||||
import { createStreamResponse } from "@lib/helpers.ts";
|
||||
import StealthPlugin from "npm:puppeteer-extra-plugin-stealth";
|
||||
import * as env from "@lib/env.ts";
|
||||
|
||||
const userAgentStrings = [
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.2227.0 Safari/537.36",
|
||||
@@ -16,9 +17,18 @@ export async function fetchHtmlWithPlaywright(
|
||||
streamResponse: ReturnType<typeof createStreamResponse>,
|
||||
): Promise<string> {
|
||||
streamResponse.enqueue("booting up playwright");
|
||||
|
||||
|
||||
const config: Parameters<typeof firefox.launch>[0] = {};
|
||||
if (env.PROXY_SERVER) {
|
||||
config.proxy = {
|
||||
server: env.PROXY_SERVER,
|
||||
username: env.PROXY_USERNAME,
|
||||
password: env.PROXY_PASSWORD,
|
||||
};
|
||||
}
|
||||
|
||||
// Launch the Playwright browser
|
||||
const browser = await firefox.launch();
|
||||
const browser = await firefox.launch(config);
|
||||
|
||||
streamResponse.enqueue("fetching html");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user