mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-24 06:30:16 +09:00
revert: 移除ddg配置代理的功能
This commit is contained in:
parent
d41cf84abc
commit
6da890e363
@ -1,9 +1,6 @@
|
|||||||
import { decode } from "html-entities";
|
import { decode } from "html-entities";
|
||||||
import { convert as htmlToText } from "html-to-text";
|
import { convert as htmlToText } from "html-to-text";
|
||||||
import { Tool } from "langchain/tools";
|
import { Tool } from "langchain/tools";
|
||||||
import fetch from "node-fetch";
|
|
||||||
|
|
||||||
const DDG_PROXY_URL = process.env.DDG_PROXY_URL;
|
|
||||||
|
|
||||||
const SEARCH_REGEX =
|
const SEARCH_REGEX =
|
||||||
/DDG\.pageLayout\.load\('d',(\[.+\])\);DDG\.duckbar\.load\('images'/;
|
/DDG\.pageLayout\.load\('d',(\[.+\])\);DDG\.duckbar\.load\('images'/;
|
||||||
@ -326,15 +323,9 @@ async function search(
|
|||||||
// cdrexp: 'b'
|
// cdrexp: 'b'
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
let proxyAgent;
|
|
||||||
if (DDG_PROXY_URL) {
|
|
||||||
const { HttpsProxyAgent } = require("https-proxy-agent");
|
|
||||||
proxyAgent = new HttpsProxyAgent(DDG_PROXY_URL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://links.duckduckgo.com/d.js?${queryString(queryObject)}`,
|
`https://links.duckduckgo.com/d.js?${queryString(queryObject)}`,
|
||||||
{ agent: proxyAgent },
|
|
||||||
);
|
);
|
||||||
const data = await response.text();
|
const data = await response.text();
|
||||||
|
|
||||||
@ -464,14 +455,8 @@ function queryString(query: Record<string, string>) {
|
|||||||
|
|
||||||
async function getVQD(query: string, ia = "web") {
|
async function getVQD(query: string, ia = "web") {
|
||||||
try {
|
try {
|
||||||
let proxyAgent;
|
|
||||||
if (DDG_PROXY_URL) {
|
|
||||||
const { HttpsProxyAgent } = require("https-proxy-agent");
|
|
||||||
proxyAgent = new HttpsProxyAgent(DDG_PROXY_URL);
|
|
||||||
}
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://duckduckgo.com/?${queryString({ q: query, ia })}`,
|
`https://duckduckgo.com/?${queryString({ q: query, ia })}`,
|
||||||
{ agent: proxyAgent },
|
|
||||||
);
|
);
|
||||||
const data = await response.text();
|
const data = await response.text();
|
||||||
return VQD_REGEX.exec(data)![1];
|
return VQD_REGEX.exec(data)![1];
|
||||||
|
@ -291,4 +291,4 @@ async function handle(req: NextRequest) {
|
|||||||
export const GET = handle;
|
export const GET = handle;
|
||||||
export const POST = handle;
|
export const POST = handle;
|
||||||
|
|
||||||
export const runtime = process.env.DDG_PROXY_URL ? "nodejs" : "edge";
|
export const runtime = "edge";
|
||||||
|
Loading…
Reference in New Issue
Block a user