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

Mounting on FastAPI deployed on Posit Connect redirects to 127.0.0.1 #1604

Open
tonisama opened this issue Dec 22, 2024 · 3 comments
Open

Mounting on FastAPI deployed on Posit Connect redirects to 127.0.0.1 #1604

tonisama opened this issue Dec 22, 2024 · 3 comments
Labels
backend Pertains to the Python backend. bug Something isn't working needs-triage

Comments

@tonisama
Copy link

Describe the bug
I've mounted my Chainlit app as a FastAPI sub-application as outlined here https://docs.chainlit.io/integrations/fastapi. I've tested this locally and it works as expected.

I tried to deploy the app as a FastAPI on Posit Connect, and when navigating to /chainlit, I get redirected to 127.0.0.1. The /docs and /app do work as expected which means FastAPI is correctly set up.

Tried adding environmental variables with no effect:
CHAINLIT_HEADLESS = true
CHAINLIT_NO_ONBOARDING = true
CHAINLIT_PUBLIC_PATH = '/chainlit'

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://docs.chainlit.io/integrations/fastapi'
  2. Copy all code into the appropriate files in a directory
  3. Deploy the app using the command line: 'rsconnect deploy fastapi --entrypoint main:app --server [your_server_URL] --api-key [your_API_key] ./
  4. Attempt to navigate to your deployed app at: '[your_app_url]/chainlit'

Expected behavior
Expect to see the app load. Instead, redirected to 127.0.0.1/[rest_of_URL]/chainlit and a 'page not found' error.

Note if mounting locally using uvicorn, the app loads fine.

@dosubot dosubot bot added backend Pertains to the Python backend. bug Something isn't working labels Dec 22, 2024
@willydouhard
Copy link
Collaborator

When started locally on the sub path is it working? What version of Chainlit are you using?

@tonisama
Copy link
Author

tonisama commented Jan 7, 2025

When started locally on the sub path is it working? What version of Chainlit are you using?

Yes, it works locally, either by using "chainlit run" or by running a FastAPI with uvicorn web server and navigating to "localhost/chainlit" I'm using 1.3.2, however I just upgraded to 2.0.0 and got the same issue.

@tonisama
Copy link
Author

tonisama commented Jan 7, 2025

Posit Support replied back saying "Chainlit doesn't appear to correctly handle running behind a proxy with a non-empty root path." I'm not sure I necessarily buy this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pertains to the Python backend. bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants