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

Chainlit unusable under proxy with request rewriting #1089

Open
akamya997 opened this issue Jun 20, 2024 · 0 comments
Open

Chainlit unusable under proxy with request rewriting #1089

akamya997 opened this issue Jun 20, 2024 · 0 comments

Comments

@akamya997
Copy link

Describe the bug
Using version 1.1.302, I tried to deploy it using docker on certain cloud service. But it can only return a blank page while working well on my local machine.
The service URL is like http://example.com/some/endpoint, but chainlit is trying to get the assets from http://example.com/assets/..., thus returning a blank page and making it unusable. Unfortunately, it is not the case that can be solved by the --root-path config which is merged in #1064.
I found that this problem is caused by request rewriting, see the following for more details.

To Reproduce
I have also tried to reproduce this problem in a local environment using Nginx.

  1. Use nginx to set up a proxy using a server config like
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;
    server_name _;

    location /endpoint {
            rewrite ^/endpoint/(.*)$ /$1 break;
            proxy_pass http://localhost:9000;
    }
}
  1. Set up chainlit service using demo.py like chainlit run demo.py -w --port 9000
  2. Visit http://localhost:8080/endpoint and see a blank page

Expected behavior
Chainlit works well under proxy with request rewriting.

Screenshots
There are some screenshots from local test.

  1. Successfully get the html file under proxy
  1. Failed to get assets due to wrong prefix, the assets should be under /endpoint/assets

Additional context
As a temporary solution, I hard coded the root-path for frontend only, which means that I modified the following lines to make it works for me:

<meta property="og:root_path" content="{ROOT_PATH}">"""

if ROOT_PATH:
content = content.replace('href="/', f'href="{ROOT_PATH}/')
content = content.replace('src="/', f'src="{ROOT_PATH}/')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant