0

我正在使用 react-social-login 扩展来通过 GitHub 进行身份验证。但是,在 Github 的重定向之后,返回一个错误: net::ERR_CONNECTION_REFUSED

在这里附上我的代码(代码是用 react 编写的,但它不应该打扰你)-

<SocialButton
    provider={'github'}
    disabled={loading}
    appId={githubAppId}
    scope={'user:email'}
    redirect='http://localhost:3000/auth'
    gatekeeper='http://localhost:9999'
    className="btn btn-dark btn-floating mb-1 w-100">
        <i className="bi-github">&emsp;Login with Github</i>
</SocialButton>

连接成功后,我将触发一个函数以从网守那里获取令牌:

useEffect(() => {
    const searchParams = new URLSearchParams(window.location.href);
    if(searchParams.has('code'))
    {
        const code = searchParams.get('code');
        $.getJSON(`http://localhost:9999/authenticate/${code}`, (response : Response) => {
            console.log(response);
        }).catch(err => console.log(err));
    }
}, [])

正如我之前所说,响应是: 响应错误

我该如何解决这个问题?很高兴得到任何帮助:)

反应社交登录: https ://www.npmjs.com/package/react-social-login

4

0 回答 0