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

国内访问不行问题 #71

Open
wsli001 opened this issue Apr 24, 2023 · 9 comments
Open

国内访问不行问题 #71

wsli001 opened this issue Apr 24, 2023 · 9 comments

Comments

@wsli001
Copy link

wsli001 commented Apr 24, 2023

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

@wsli001
Copy link
Author

wsli001 commented Apr 25, 2023

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

@stevenlee87
Copy link

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

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

@esroom
Copy link

esroom commented Apr 27, 2023

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

@hahahumble
Copy link
Owner

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

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

image-ZoX6rP7U

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

@erbanku
Copy link

erbanku commented Apr 27, 2023

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

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

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

image-ZoX6rP7U

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

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

@erbanku
Copy link

erbanku commented May 3, 2023

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

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

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

@esroom
Copy link

esroom commented May 4, 2023

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

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

image-ZoX6rP7U

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

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

@xinlake
Copy link

xinlake commented May 10, 2023

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

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

7 participants