Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
duan135246 opened this issue May 27, 2024 · 13 comments
Open

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

duan135246 opened this issue May 27, 2024 · 13 comments

Comments

@duan135246
Copy link

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
Copy link

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

@Issues-translate-bot
Copy link

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


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

@Dean-YZG
Copy link
Contributor

do you have any screenshot about error log?

@daiaji
Copy link

daiaji commented May 27, 2024

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

@Issues-translate-bot
Copy link

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
Copy link

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

@Issues-translate-bot
Copy link

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
Copy link

daiaji commented May 28, 2024

只能说 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
Copy link

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
Copy link

daiaji commented Jul 3, 2024

抢救不了半点?

@Issues-translate-bot
Copy link

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


Can't save anything?

@iamananba
Copy link

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

@Issues-translate-bot
Copy link

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


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants