hahahumble / speechgpt

💬 SpeechGPT is a web application that enables you to converse with ChatGPT.
https://speechgpt.app
MIT License
2.72k stars 404 forks source link

国内访问不行问题 #71

Open wsli001 opened 1 year ago

wsli001 commented 1 year ago

我试了下,把openai.com加入白名单国内就能正常使用了…

wsli001 commented 1 year ago

fork的另一个项目,部署到vercel再绑定自己的域名,国内就可以正常访问,请问有办法解决么,非常感谢

stevenlee87 commented 1 year ago

fork的另一个项目,部署到vercel再绑定自己的域名,国内就可以正常访问,请问有办法解决么,非常感谢

我也尝试用cname的方式做解析,国内虽然可以访问,但是没有梯子的话,还是无法正常的提问回答。

esroom commented 1 year ago

遇到同样的问题,解析域名后仍然要走代理才能用,同样的方法基于https://github.com/Chanzhaoyu/chatgpt-web 搭建的对话不需要代理,请问有什么办法吗?

hahahumble commented 1 year ago

目前请求是从客户端发出的,因此需要用代理才能正常使用,这可以通过自行部署的 OpenAI 地址解决,参考:https://github.com/noobnooc/noobnooc/discussions/9

此外,如果使用的是 speechgpt.app 官网,可以使用已经部署好的地址:https://github.com/hahahumble/worker-openai-proxy

image-ZoX6rP7U

在设置中填入地址之后,在内地不需要代理也可以正常使用。

erbanku commented 1 year ago

You can solve this issue by creating your own API proxy service or using the API proxy below:

openai-api-proxy.erbanku.com

Rest assured. Even if you used the API proxy, I can't get your OpenAI API key. There is no nonsense involved – it follows a no-bullshit policy.

Proxy implemented code ``` const TELEGRAPH_URL = 'https://api.openai.com'; addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const url = new URL(request.url); const headers_Origin = request.headers.get("Access-Control-Allow-Origin") || "*" 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); // Add a response header that allows cross-domain access modifiedResponse.headers.set('Access-Control-Allow-Origin', headers_Origin); return modifiedResponse; } ```
Linaom1214 commented 1 year ago

目前请求是从客户端发出的,因此需要用代理才能正常使用,这可以通过自行部署的 OpenAI 地址解决,参考:noobnooc/noobnooc#9

此外,如果使用的是 speechgpt.app 官网,可以使用已经部署好的地址:https://github.com/hahahumble/worker-openai-proxy

image-ZoX6rP7U

在设置中填入地址之后,在内地不需要代理也可以正常使用。

自己部署的网页也可以使用 ‘api.speech.com’吗? 这里不太懂 vercel 本来就是免翻为什么还要代理?

erbanku commented 1 year ago

目前请求是从客户端发出的,因此需要用代理才能正常使用,这可以通过自行部署的 OpenAI 地址解决,参考:noobnooc/noobnooc#9 此外,如果使用的是 speechgpt.app 官网,可以使用已经部署好的地址:hahahumble/worker-openai-proxy image-ZoX6rP7U 在设置中填入地址之后,在内地不需要代理也可以正常使用。

自己部署的网页也可以使用 ‘api.speech.com’吗? 这里不太懂 vercel 本来就是免翻为什么还要代理?

是的,自己部署的也可以用该 Proxy URL. 要代理是因为请求不是通过 Vercel 发出的,而是通过用户客户端发出的。你可以在部署时通过环境变量配置 OpenAI API Host ,这样就不需要开代理或者在网页前端输入代理了。

esroom commented 1 year ago

目前请求是从客户端发出的,因此需要用代理才能正常使用,这可以通过自行部署的 OpenAI 地址解决,参考:noobnooc/noobnooc#9

此外,如果使用的是 speechgpt.app 官网,可以使用已经部署好的地址:https://github.com/hahahumble/worker-openai-proxy

image-ZoX6rP7U

在设置中填入地址之后,在内地不需要代理也可以正常使用。

十分感谢,用这个方法可以了!

xinlake commented 1 year ago

有计划改为从服务端 OpenAI 向发起请求吗?客户端不与 OpenAI 直接通讯,这样不需要客户端走国际网络。