Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.25k stars 799 forks source link

Runing on server emitting ERROR: "auth0-spa-js must run on a secure origin." #20

Closed qiuhuachuan closed 1 year ago

qiuhuachuan commented 1 year ago

my code is shown in following

import uuid
from dataclasses import dataclass

import requests
import chainlit as cl

@dataclass
class ChatInfo:
    owner: str
    msg: str
    unique_id: str

@cl.on_chat_start
def start():
    unique_id = str(uuid.uuid1())
    cl.user_session.set('key', unique_id)

@cl.on_message
def main(msg: str):
    # Your custom logic goes here...

    unique_id = cl.user_session.get('key')

    owner = 'seeker'
    SeekerChatInfo: ChatInfo = {
        'owner': owner,
        'msg': msg,
        'unique_id': unique_id
    }
    try:
        res = requests.post(url='http://xxx/v1/chat', # my URL 
                            json=SeekerChatInfo)
        print(res.status_code)
        res = res.json()
        print('res', res)
        response = res['item']['msg']
        # Send a response back to the user
        cl.send_message(content=response)
    except Exception as e:
        print(f'ERROR: {e}')
        # Send a response back to the user
        cl.send_message(content='Server ERROR')

I run it on terminal with the command chainlit run app.py --port 8081 --host 0.0.0.0 --headless Until now it is ok

But if I input my server address on the browser, nothing shown on the web page

image
willydouhard commented 1 year ago

I assume your server does not have an https certificate and you are connecting with http?

qiuhuachuan commented 1 year ago

Actually yes I just use the server's IP connecting with HTTP

willydouhard commented 1 year ago

So that is the issue, if your server is not running on local host, you need to connect with https

prasad4fun commented 1 year ago

So that is the issue, if your server is not running on local host, you need to connect with https

Hi, In my case i hosted the chainlit service(using --host 0.0.0.0) in one of the LAN machines. Im trying to access this service from my laptop which is connected to LAN as well. Im getting the same error (Uncaught Error: auth0-spa-js must run on a secure origin).

As per your comment connecting with https should solve the issue, but since its running on localhost i can connect only via http, any alternatives to solve this issue?

willydouhard commented 1 year ago

What Chainlit version are you running? This was fixed in 0.3.0 or 0.4.0 if I recall correctly.