a16z-infra / companion-app

AI companions with memory: a lightweight stack to create and host your own AI companions
https://ai-companion-stack.com/
MIT License
5.76k stars 959 forks source link

http://localhost:3000 redirect after deploy at fly.io (after Clerk auth) #73

Closed nttylock closed 1 year ago

nttylock commented 1 year ago

Hello everyone,

First of all, I apologize in advance if my questions seem basic - I'm still learning and I'm very much in the beginner stages.

I've been following the README instructions of my project meticulously. Everything works perfectly fine local, and I have successfully deployed the application to Fly.io.

However, things take a turn for the worse when I attempt to log in. After entering my credentials (Clerk), I get redirected to this URL:

http://localhost:3000/#__clerk_db_jwt[eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXYiOiJkdmJfMlNsZUZHOGlqNlZGb3lleWF0Rk5GMThVNUJKIn0.x8TQP_RZ1iWQDB52Rj4I7RBYqRI-nZcpYizDftav_V_zO4P6qW9zSMP_KEQPDSxPD6hXCpKGuDwj33LCOq2Z42Uc-OEKoLsrbWBHDp9DXPCJFPo_tCQ1GUmC4bkBWGIiEXkG6mYVhgjjXIatLQeL9qTqn-YPFrkHqD8ocZu4mam2YZ5U0alACrlsbVJXJ0-QJFmzjQRcIgkZ66eOIhPWNSly1MFc2tXHNlRUB-ci6iwq74MmhTby-xOF50wEiiyVDY7C59HIupcpU4kI6ZSjFPdY2PMQgyzKeh03SxbPJgXe8O--cTA4zCRNXKHT-oQEfwk8VchQgeXcaMVWQj5PQA]

Unfortunately, it leads to nowhere and I'm at a loss as to what went wrong. I understand that there is something amiss with my setup, but being a novice, I'm unable to pinpoint the exact problem.

I would greatly appreciate it if anyone could offer some guidance or insights on this.

Thank you so much in advance for your time and patience!

ykhli commented 1 year ago

Ah! I should really add this to FAQ

You can fix this by adding CLERK_USE_X_FWD_HEADERS=true to .env.local (or .env.prod) and deploy again. Please let me know if it works!

nttylock commented 1 year ago

Thanks you very much, resolved! Very appreciated.

gvzdv commented 1 year ago

Hi @ykhli! Thank you for the fix. It helped me to get rid of the same problem (redirection to localhost), but now I get port 80 in my URL. When I manually delete ":80" from the URL, redirection works. Can you please help me try to find a solution to this problem?

Fly.io was down for some time yesterday, so I launched the project using Google Cloud Run. The URL looks like this: https://ai-bro-5oxslodcwq-uc.a.run.app:80/sign-in?redirect_url=https%3A%2F%2Fai-bro-5oxslodcwq-uc.a.run.app%3A80%2F#__clerk_db_jwt[eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXYiOiJkdmJfMlNtQXNodkYyN0dkdkF4UnRyekw2SnZJOTB6In0.Xq2T0PdayYJqOOFvOaapXNC7neWD-_1pbvNTniRWkG9QaUGL3x8soWOpvfQyRFXUOJpOXMbzViEFWQIbxgiWaRJH3pt9QU9K96fVFVh8ctT8czcH6b5zivwhAUwRLUrhi4DUlanFa7kvEiHskMX7lYTrag2hqLEXriSTx-OxEy606HEPPv3C5RYCZWVFyIOT_h5sreSfBX7oZH77AWq1LggKP-NcZzXNVXLx72LH_Zg1PLv8lSwDIz1sKxUPFxhThWX_EZpCkXI0zTbjIogFtqj8Ae60jFsdkeqqlOYwbmGZ802S_8Jw9VTnAh-ZwE_IBuRrVaBSb09i8kBcDvmvOQ]