ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

Localhost refuses to connect

Open kvongole328 opened this issue 2 years ago • 8 comments

I have my Github client id and secret set up as well as the NEXTAUTH_URL. I'm seeing the Github login screen on localhost:3000 and able to click sign in and sign into my Github. However, once Github sign in is completed the whole app just crashes with localhost refusing to connect and the actual process quitting on terminal.

local_host_issue terminal

Home page URL in github: http://localhost:3000/ Authorization Callback URL in Github: http://localhost:3000/api/auth/callback/github

kvongole328 avatar Dec 08 '23 23:12 kvongole328

Hello. Make sure you have updated Nextjs to the latest version pnpm i next@latest which is "next": "14.0.4" in package.json. The canary version that the template suggest downloading causes this issue.

Alexandru177 avatar Dec 09 '23 11:12 Alexandru177

Hello, me I have a problem with connection, how to repair this ? image

arthurbret avatar Dec 27 '23 17:12 arthurbret

Hello, me I have a problem with connection, how to repair this ?

same issue

josh3io avatar Jan 05 '24 20:01 josh3io

@arthurbret @josh3io make sure you're using pnpm instead of npm and also setting the VERCEL_URL in your .env.local to your real URL. doing both of those fixed it for me.

voltron33 avatar Jan 09 '24 16:01 voltron33

how do you login locally with github?

markojak avatar Jan 10 '24 21:01 markojak

how do you login locally with github?

I'm having the same issue, I think. My project runs locally but upon clicking "Login with GitHub" it logs me in but takes me to the HOSTED version on my Vercel account rather than back to my localhost. If I manually navigate back to localhost, I am not authenticated and the sign-in page appears again.

I'm not sure if I need to set the authorization callback URL, and if so, I'm not sure how. The URL in localhost appears to be pointing back to the correct URL: http://localhost:3000/sign-in?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2F

@voltron33 when you say set the VERCEL_URL to your "real" URL which URL do you mean? Localhost or the production Vercel app? As you can see from my comment above, I'm having an issue where regardless of what I've set VERCEL_URL to, the "Login with GitHub" button takes me through the auth process and then redirects me back to the version I have hosted on Vercel. Thank you!

probrandono avatar Feb 09 '24 22:02 probrandono

in your .env.local:

AUTH_REDIRECT_PROXY_URL="http://localhost:3000/api/auth"

On Fri, Feb 9, 2024 at 2:59 PM Brandon @.***> wrote:

how do you login locally with github?

I'm having the same issue, I think. My project runs locally but upon clicking "Login with GitHub" it logs me in but takes me to the HOSTED version on my Vercel account rather than back to my localhost. If I manually navigate back to localhost, I am not authenticated and the sign-in page appears again.

I'm not sure if I need to set the authorization callback URL, and if so, I'm not sure how. The URL in localhost appears to be pointing back to the correct URL: http://localhost:3000/sign-in?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2F

— Reply to this email directly, view it on GitHub https://github.com/vercel/ai-chatbot/issues/201#issuecomment-1936713760, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6KYTWITOALIUFT6S5MZ3YS2S5BAVCNFSM6AAAAABANJQ7Y2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZWG4YTGNZWGA . You are receiving this because you were mentioned.Message ID: @.***>

josh3io avatar Feb 12 '24 19:02 josh3io

@josh3io thank you! I will try this next.

What ended up working for me was to change the Homepage URL and Authorization callback URL inside GitHub Developer settings for the app to point to my local URLs. Of course this broke the deployed version I have but I couldn't find any way to separate the settings per environment like you can with keys.

probrandono avatar Feb 20 '24 16:02 probrandono