FlowiseAI / FlowiseChatEmbed

276 stars 1.17k forks source link

Embedding the flowise chat-bot with default nginx index.html caused CORS issue. #169

Closed quzhixue-Kimi closed 1 month ago

quzhixue-Kimi commented 1 month ago

hi there,

I just test the flowise chat-bot with defaul nginx index.html page with following steps:

  1. There has been a flowise flow with host like 'aiflowise.kq.eu.org'

    Screenshot 2024-05-24 at 14 51 39
  2. There has been another default nginx index.html page with host like 'abc-18688.xyz'.

Following the code as doc showing to insert below code into the default index.html.

  1. Reload the nginx process, and the chat-bot has been displayed. But, the page got the issue

Access to fetch at 'https://aiflowise.kq.eu.org/api/v1/chatflows-streaming/b8f72c44-1502-4c86-bc96-ef799660a4d1' from origin 'https://abc-18688.xyz' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

'Access to XMLHttpRequest at 'https://aiflowise.kq.eu.org/socket.io/?EIO=4&transport=polling&t=O-fPO6P' from origin 'https://abc-18688.xyz' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.'

Is there any configuration that I missed?

The nginx.conf configued with these headers

location / { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; add_header 'Access-Control-Expose-Headers' 'Content-length, Content-Range'; root /var/www/html; index index.html; }

Any suggestion or feedback is appreciated.

BR

Kimi

HenryHengZJ commented 1 month ago

You'll have to specify env variables in your .env file - https://docs.flowiseai.com/using-flowise/embed#cors

quzhixue-Kimi commented 1 month ago

Hi there,

Thank you for your helpful information.

Issue has been fixed based on the document.

BR Kimi