GenAIExamples icon indicating copy to clipboard operation
GenAIExamples copied to clipboard

[Bug] VisualQnA UI can't access to backend service due to CORS

Open ezelanza opened this issue 1 year ago • 2 comments

Priority

Undecided

OS type

Ubuntu

Hardware type

Gaudi2

Installation method

  • [X] Pull docker images from hub.docker.com
  • [ ] Build docker images from source

Deploy method

  • [X] Docker compose
  • [ ] Docker
  • [ ] Kubernetes
  • [ ] Helm

Running nodes

Single Node

What's the version?

Repo

Description

Request from the UI to the backend service seems to be blocked by CORS policy.

Screenshot 2024-08-30 at 10 55 20 AM

It works when I test it from any terminal

~ % curl http://${host_ip}:8888/v1/visualqna -H "Content-Type: application/json" -d '{
     "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What'\''s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://www.ilankelman.org/stopsigns/australia.jpg"
            }
          }
        ]
      }
    ],
    "max_tokens": 300
    }'
{"id":"chatcmpl-MUqRQ3gWyBjAJqnn4nLuvP","object":"chat.completion","created":1725029828,"model":"visualqna","choices":[{"index":0,"message":{"role":"assistant","content":"The image shows a stop sign at the corner of a street, with a traditional Chinese archway or gateway in the background. There is also a black car driving past the stop sign. The scene suggests a blend of Western and Eastern architectural styles. "},"finish_reason":"stop"}],"usage":{"prompt_tokens":0,"total_tokens":0,"completion_tokens":0}}%  ```


### Reproduce steps

```cd docker/gaudi/```

```docker compose up -d```

Try host_ip:5173 in a browser and got time out. Chechking the inspector a CORS restriction is found

### Raw log

_No response_

ezelanza avatar Sep 03 '24 14:09 ezelanza

Refer to here

What is CORS about? It's purpose is to mainly prevent the usage of a (malicious) HTTP call from a non-whitelisted frontend to your backend with some critical mutation. ...... How to solve? ...... provide something like Access-Control-Allow-Origin: http://localhost:3000 (or any other port you'll be using). ......

feng-intel avatar Sep 04 '24 07:09 feng-intel

Exactly, but it should be solved on the backend (within the container). I think since it’s a security issue i imagine it should have to be sent as env when the container launches

ezelanza avatar Sep 04 '24 13:09 ezelanza

@ezelanza, We have deployed a Nignx service in the pipeline, so this issue should be fixed. Please try the latest image.

lvliang-intel avatar Nov 03 '24 10:11 lvliang-intel

Close this issue as two weeks no response and this issue has already been fixed.

lvliang-intel avatar Nov 20 '24 06:11 lvliang-intel