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

proxy代理地址失效,无法登录使用 #537

Open
ymkNK opened this issue Nov 2, 2022 · 7 comments
Open

proxy代理地址失效,无法登录使用 #537

ymkNK opened this issue Nov 2, 2022 · 7 comments

Comments

@ymkNK
Copy link

ymkNK commented Nov 2, 2022

Gitalk 版本

1.8.0

问题描述

proxy代理地址失效,无法登录使用,目前用在纯静态站点上的,有无比较好的解决方式?

@CodeZhangBorui
Copy link

Error: Network Error

@wbb-007
Copy link

wbb-007 commented Nov 10, 2022

我也想问,整的我都想换了

@nenge123
Copy link

Gitalk 版本

1.8.0

问题描述

proxy代理地址失效,无法登录使用,目前用在纯静态站点上的,有无比较好的解决方式?

有些国内空间商有优惠,VPS一两百一年.
然后做代理,记得去host 指定github ip
PHP代码参考,其他参考自行百度如Pyth

<?php
	header("Access-Control-Allow-Origin:*");
	header("Expires: 0"); // 向后兼容HTTP/1.0   
	header("Pragma: no-cache"); // 支持HTTP/1.1   
	header("Cache-Control: no-cache,no-store,max-age=0,s-maxage=0,must-revalidate");
	header("Content-type: application/json");
//header("Access-Control-Allow-Methods:retroarch.nenge.net,*);
//header("Access-Control-Allow-Origin:retroarch.nenge.net,*");
$json = file_get_contents('php://input');
if ($json) {
	function getRequest($url, $post = false, $cookie = array(), $refer = "", $timeout = 5)
	{
		//$url, $post = array(), $timeout = 30, $times = 1$header = []
		$ssl = stripos($url, 'https://') === 0 ? true : false;
		$curlObj = curl_init();
		$header = [];
		$options = [
			CURLOPT_URL => $url,
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_FOLLOWLOCATION => 1,
			CURLOPT_AUTOREFERER => 1,
			CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)',
			CURLOPT_TIMEOUT => $timeout,
			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
			CURLOPT_HTTPHEADER => ['Expect:'],
			//'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4,
			//'CURLOPT_REFERER' => $url, //伪造来路
		];
		if ($refer) {
			$options[CURLOPT_REFERER] = $refer;
		}
		if ($ssl) {
			//support https
			$options[CURLOPT_SSL_VERIFYHOST] = false;
			$options[CURLOPT_SSL_VERIFYPEER] = false;
		}
		if (is_array($cookie)) $cookie = http_build_query($cookie);
		if ($cookie) {
			$header = array('Content-type: application/x-www-form-urlencoded', 'X-Requested-With: XMLHttpRequest');
			$header[] = "Cookie: $cookie";
		}
		if ($post) {
			$options[CURLOPT_POST] = 1;
			if (is_array($post)) {
				$options[CURLOPT_POSTFIELDS] =  json_encode($post);
			} else {
				$header = array(
					'accept: application/json',
					'Content-Type:application/json;charset=utf-8',
					'Content-Length:' . strlen($post), 'accept:application/json'
				);
				$options[CURLOPT_POSTFIELDS] =  $post;
			}
		}
		$options[CURLOPT_HTTPHEADER] = $header;
		curl_setopt_array($curlObj, $options);
		$returnData = curl_exec($curlObj);
		if (curl_errno($curlObj)) {
			//error message
			$returnData = json_encode(array('error' => curl_error($curlObj)));
			//echo $returnData;
			//exit;
		}
		curl_close($curlObj);
		return $returnData;
	}
	$json = json_decode($json, true);
	//$json['client_id'] = '';
	//$json['client_secret'] = '';
	echo getRequest('https://github.com/login/oauth/access_token/', json_encode($json));
}else{
	echo '{"error":"nothing post"}';
}
exit;

@huixpp
Copy link

huixpp commented Jul 13, 2023

vercel反代理

@gittyspirit
Copy link

用worker

@huixpp
Copy link

huixpp commented Sep 9, 2023

用worker

这个方法可以,但是速度较慢,并且worker.dev已经被墙了

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