chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

BUG: Double root_path

Open marsanla opened this issue 1 year ago • 2 comments
trafficstars

Describe the bug When running a Chainlit app with a FastAPI backend, everything works fine when using the standalone Chainlit app. However, the subpath is duplicated in the frontend when mounting Chainlit under a root URL path (e.g., /chat). For instance, if I attempt to access a resource (e.g. TaskList), it is rendered as http://localhost:8000/chat/project/file/0f7d5f5a-31f3-46ba-b261-7b2dc3ac3198?session_id=eb4613cf-059a-4853-943a-b57e43d4c5a8, causing the frontend to fail in loading resources.

To Reproduce Steps to reproduce the behavior:

  1. Run the Chainlit app with FastAPI.
  2. Mount Chainlit under a URL folder mount_chainlit(app=app, target='chat/main.py', path='/chat').
  3. Try to access a resource from the frontend (tasklist).
  4. See the error where the path is duplicated (e.g., http://localhost:8000/chat/project/file/0f7d5f5a-31f3-46ba-b261-7b2dc3ac3198?session_id=eb4613cf-059a-4853-943a-b57e43d4c5a8).

Expected behavior The expected behavior is that the frontend should not duplicate the subpath. The resource should be accessed correctly as http://localhost:8000/chat/project/file/0f7d5f5a-31f3-46ba-b261-7b2dc3ac3198?session_id=eb4613cf-059a-4853-943a-b57e43d4c5a8

Screenshots

Captura de pantalla 2024-10-03 a las 6 24 27 Captura de pantalla 2024-10-03 a las 6 25 16

Desktop (please complete the following information):

  • OS: macOS Sonoma
  • Browser: Chrome, Safari
  • Version: Latest

Additional context The issue seems specific to the URL path duplication when Chainlit is mounted under a folder in FastAPI. When using the standalone app, the frontend works as expected.

marsanla avatar Oct 03 '24 04:10 marsanla