ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
75.4k stars 58.87k forks source link

为什么cloudflare配置Gemini的代理用不了 #4783

Open duan135246 opened 4 months ago

duan135246 commented 4 months ago

const TELEGRAPH_URL = 'https://generativelanguage.googleapis.com/';

addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) })

async function handleRequest(request) { const url = new URL(request.url); url.host = TELEGRAPH_URL.replace(/^https?:\/\//, '');

const modifiedRequest = new Request(url.toString(), { headers: request.headers, method: request.method, body: request.body, redirect: 'follow' });

const response = await fetch(modifiedRequest); const modifiedResponse = new Response(response.body, response);

// 添加允许跨域访问的响应头 modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');

return modifiedResponse; }

我把openai的网址换成Gemini的为啥用不了,填openAI的网址国内可以访问。

nextchat-manager[bot] commented 4 months ago

Please follow the issue template to update title and description of your issue.

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: Why can’t cloudflare configure Gemini’s proxy?

Dean-YZG commented 4 months ago

do you have any screenshot about error log?

daiaji commented 4 months ago

确实,隔壁lobe就能用cf的反代。

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Indeed, the lobby next door can use the reverse generation of cf.

QAbot-zh commented 4 months ago

只能说 OpenAI 支持的 IP 范围比 Gemini 宽松,不同公司不具备可比性

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


It can only be said that the IP range supported by OpenAI is looser than Gemini, and different companies are not comparable.

daiaji commented 4 months ago

只能说 OpenAI 支持的 IP 范围比 Gemini 宽松,不同公司不具备可比性

不全是,我能够通过优选CF的入站节点控制其出站节点。 但依旧没法解决反代只能在lobe用,Next用不了的情况。 netlify上的反代也一样。

podman logs chatgpt-next-web
   ▲ Next.js 14.1.1
   - Local:        http://vps:2999
   - Network:      http://10.10.10.10:2999

 ✓ Ready in 63ms
[Server Config] using 1 of 1 api key - sk-fffffffffffffffffffffffffffffffffffffffffffffff
[Server Config] using 1 of 1 api key - fffffffffffffffffffffffffffffffffffffffffffffff
[Google Route] params  {
  path: [ 'v1beta', 'models', 'gemini-1.5-flash-latest:streamGenerateContent' ]
}
[Server Config] using 1 of 1 api key - sk-fffffffffffffffffffffffffffffffffffffffffffffff
[Server Config] using 1 of 1 api key - fffffffffffffffffffffffffffffffffffffffffffffff
[Proxy]  v1beta/models/gemini-1.5-flash-latest:streamGenerateContent
[Base Url] https://earnest-cajeta-c38f66.netlify.app
[Server Config] using 1 of 1 api key - sk-fffffffffffffffffffffffffffffffffffffffffffffff
[Server Config] using 1 of 1 api key - fffffffffffffffffffffffffffffffffffffffffffffff
[Auth] allowed hashed codes:  [ 'fffffffffffffffffffffffffffffffffffffffffffffff' ]
[Auth] got access code: fffff
[Auth] hashed access code: fffffffffffffffffffffffffffffffffffffffffffffff
[User IP]  10.10.10.244
[Time]  5/28/2024, 11:36:46 AM
[Server Config] using 1 of 1 api key - sk-fffffffffffffffffffffffffffffffffffffffffffffff
[Server Config] using 1 of 1 api key - fffffffffffffffffffffffffffffffffffffffffffffff
[Auth] use system api key

日志也没用什么。 https://github.com/antergone/palm-netlify-proxy 这边可以直接一键在netlify部署反代。 https://sharegpt.com/c/f2iDduL 总之就会一直卡住。 和assistant的对话就就会一直“正在输入” 屏幕截图_20240528_163427

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


It can only be said that the IP range supported by OpenAI is looser than Gemini, and different companies are not comparable.

Not really, I am able to control the outbound nodes via the inbound node of preferred CF. But there is still no way to solve the problem that anti-generation can only be used in lobe and not in Next.

daiaji commented 3 months ago

抢救不了半点?

Issues-translate-bot commented 3 months ago

Bot detected the issue body's language is not English, translate it automatically.


Can't save anything?

iamananba commented 2 months ago

const response = await fetch(modifiedRequest); 会导致流式阻塞吧?

Issues-translate-bot commented 2 months ago

Bot detected the issue body's language is not English, translate it automatically.


const response = await fetch(modifiedRequest); Will it cause streaming obstruction?