the problem of CORS #125

Closed
opened 2025-11-11 14:07:06 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @heweapon on GitHub (Dec 27, 2023).

Description

I installed Docker on my Intranet server, and used Docker to install ollama and ollama-webui. But I had a CORS problem when I accessed 172.16.120.14:3000 in my browser.

Environment

  • Operating System: Ubuntu 20.04
  • Browser (if applicable): Chrome 120.0

Browser Console Logs:
Access to fetch at 'http://172.16.120.14:11434/api/tags' from origin 'http://172.16.120.14:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.
error

Docker Container Logs:
[Include relevant Docker container logs, if applicable]
ollama:
[GIN] 2023/12/27 - 06:07:12 | 403 | 39.2µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 06:47:51 | 403 | 35.61µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 06:47:51 | 403 | 7.128µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 06:47:51 | 403 | 5.274µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 07:20:38 | 403 | 38.184µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:20:38 | 403 | 7.037µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:20:38 | 403 | 5.373µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 07:26:08 | 403 | 46.365µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:26:08 | 403 | 8.551µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:26:08 | 403 | 5.66µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 07:26:24 | 403 | 7.069µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:26:24 | 403 | 5.716µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 07:26:24 | 403 | 5.52µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 08:01:44 | 403 | 44.372µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 08:01:44 | 403 | 8.07µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 08:01:44 | 403 | 5.88µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 08:33:52 | 403 | 39.596µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 08:33:52 | 403 | 5.538µs | 118.229.3.242 | OPTIONS "/api/tags"
[GIN] 2023/12/27 - 08:33:52 | 403 | 5.496µs | 118.229.3.242 | OPTIONS "/api/version"
[GIN] 2023/12/27 - 08:40:40 | 403 | 43.403µs | 118.229.3.242 | OPTIONS "/api/tags"
ollama-webui:
INFO: Started server process [7]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO: 172.16.45.133:49450 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:49450 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:49817 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:49817 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:49875 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:49875 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:49921 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:49921 - "GET / HTTP/1.1" 200 OK
INFO: Started server process [7]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO: 172.16.45.133:61932 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:61932 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:54970 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:54970 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:57974 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/entry/start.8115b78a.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/scheduler.0545783f.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57975 - "GET /_app/immutable/chunks/singletons.a381321d.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/index.323ffc89.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57975 - "GET /_app/immutable/entry/app.019d04ff.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/index.3f9f9994.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/nodes/0.4c5a803d.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/Toaster.svelte_svelte_type_style_lang.7710012c.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57975 - "GET /_app/immutable/assets/Toaster.3a6d0da3.css HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/navigation.5cf1b549.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/each.2de3855a.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57975 - "GET /_app/immutable/assets/0.d675630a.css HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/nodes/1.715ead6c.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/stores.ab55a33e.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57978 - "GET /_app/immutable/nodes/2.916338f1.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57975 - "GET /_app/immutable/chunks/index.181feede.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57979 - "GET /_app/immutable/chunks/Advanced.fdb0c2b3.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57976 - "GET /_app/immutable/assets/2.f48dc938.css HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57980 - "GET /_app/immutable/nodes/3.b1332545.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57978 - "GET /_app/immutable/chunks/Navbar.028211d8.js HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /_app/immutable/assets/Navbar.e3b04202.css HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:57974 - "GET /assets/fonts/Arimo-Variable.ttf HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:57974 - "GET /ollama.png HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:63150 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:63389 - "GET / HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:63389 - "GET /favicon.png HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:63389 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:63390 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:65151 - "GET / HTTP/1.1" 200 OK
INFO: 172.16.45.133:50175 - "GET /manifest.json HTTP/1.1" 304 Not Modified
INFO: 172.16.45.133:55213 - "GET / HTTP/1.1" 200 OK

Originally created by @heweapon on GitHub (Dec 27, 2023). ## Description I installed Docker on my Intranet server, and used Docker to install ollama and ollama-webui. But I had a CORS problem when I accessed 172.16.120.14:3000 in my browser. ## Environment - **Operating System:** Ubuntu 20.04 - **Browser (if applicable):** Chrome 120.0 **Browser Console Logs:** Access to fetch at 'http://172.16.120.14:11434/api/tags' from origin 'http://172.16.120.14:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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. ![error](https://github.com/ollama-webui/ollama-webui/assets/49176896/c1f65924-6607-426d-8494-e351e1945295) **Docker Container Logs:** [Include relevant Docker container logs, if applicable] ollama: [GIN] 2023/12/27 - 06:07:12 | 403 | 39.2µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 06:47:51 | 403 | 35.61µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 06:47:51 | 403 | 7.128µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 06:47:51 | 403 | 5.274µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 07:20:38 | 403 | 38.184µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:20:38 | 403 | 7.037µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:20:38 | 403 | 5.373µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 07:26:08 | 403 | 46.365µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:26:08 | 403 | 8.551µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:26:08 | 403 | 5.66µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 07:26:24 | 403 | 7.069µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:26:24 | 403 | 5.716µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 07:26:24 | 403 | 5.52µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 08:01:44 | 403 | 44.372µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 08:01:44 | 403 | 8.07µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 08:01:44 | 403 | 5.88µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 08:33:52 | 403 | 39.596µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 08:33:52 | 403 | 5.538µs | 118.229.3.242 | OPTIONS "/api/tags" [GIN] 2023/12/27 - 08:33:52 | 403 | 5.496µs | 118.229.3.242 | OPTIONS "/api/version" [GIN] 2023/12/27 - 08:40:40 | 403 | 43.403µs | 118.229.3.242 | OPTIONS "/api/tags" ollama-webui: INFO: Started server process [7] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) INFO: 172.16.45.133:49450 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:49450 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:49817 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:49817 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:49875 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:49875 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:49921 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:49921 - "GET / HTTP/1.1" 200 OK INFO: Started server process [7] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) INFO: 172.16.45.133:61932 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:61932 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:54970 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:54970 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:57974 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/entry/start.8115b78a.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/scheduler.0545783f.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57975 - "GET /_app/immutable/chunks/singletons.a381321d.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/index.323ffc89.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57975 - "GET /_app/immutable/entry/app.019d04ff.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/index.3f9f9994.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/nodes/0.4c5a803d.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/Toaster.svelte_svelte_type_style_lang.7710012c.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57975 - "GET /_app/immutable/assets/Toaster.3a6d0da3.css HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/chunks/navigation.5cf1b549.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/each.2de3855a.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57975 - "GET /_app/immutable/assets/0.d675630a.css HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/nodes/1.715ead6c.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/chunks/stores.ab55a33e.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57978 - "GET /_app/immutable/nodes/2.916338f1.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57975 - "GET /_app/immutable/chunks/index.181feede.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57979 - "GET /_app/immutable/chunks/Advanced.fdb0c2b3.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57976 - "GET /_app/immutable/assets/2.f48dc938.css HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57980 - "GET /_app/immutable/nodes/3.b1332545.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57978 - "GET /_app/immutable/chunks/Navbar.028211d8.js HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /_app/immutable/assets/Navbar.e3b04202.css HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:57974 - "GET /assets/fonts/Arimo-Variable.ttf HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:57974 - "GET /ollama.png HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:63150 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:63389 - "GET / HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:63389 - "GET /favicon.png HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:63389 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:63390 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:65151 - "GET / HTTP/1.1" 200 OK INFO: 172.16.45.133:50175 - "GET /manifest.json HTTP/1.1" 304 Not Modified INFO: 172.16.45.133:55213 - "GET / HTTP/1.1" 200 OK
Author
Owner

@tjbck commented on GitHub (Dec 27, 2023):

Hi! Could you verify that ollama api url is set to /ollama/api in the webui settings? Thanks.
image

@tjbck commented on GitHub (Dec 27, 2023): Hi! Could you verify that ollama api url is set to `/ollama/api` in the webui settings? Thanks. ![image](https://github.com/ollama-webui/ollama-webui/assets/25473318/a8035b60-3c7c-4b8c-85f6-66c20bea3d7c)
Author
Owner

@heweapon commented on GitHub (Dec 27, 2023):

Hi! Could you verify that ollama api url is set to /ollama/api in the webui settings? Thanks. image

yes.But new problem as follow:
Uploading error2.png…

{detail: 'Ollama WebUI: Server Connection Error', message: "HTTPConnectionPool(host='host.docker.internal', po…ker.internal timed out. (connect timeout=None)'))"}
detail
"Ollama WebUI: Server Connection Error"
message

"HTTPConnectionPool(host='host.docker.internal', port=11434): Max retries exceeded with url: /api/tags (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fd3a11aef10>, 'Connection to host.docker.internal timed out. (connect timeout=None)'))"

@heweapon commented on GitHub (Dec 27, 2023): > Hi! Could you verify that ollama api url is set to `/ollama/api` in the webui settings? Thanks. ![image](https://private-user-images.githubusercontent.com/25473318/292995239-a8035b60-3c7c-4b8c-85f6-66c20bea3d7c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDM2NjcwNjYsIm5iZiI6MTcwMzY2Njc2NiwicGF0aCI6Ii8yNTQ3MzMxOC8yOTI5OTUyMzktYTgwMzViNjAtM2M3Yy00YjhjLTg1ZjYtNjZjMjBiZWEzZDdjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjI3VDA4NDYwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEzMDliMDVmZDc3ZDc4OTg5Y2E4OWYyMmRlYjQwMGMxODYyM2U5MjQ0NGY4YjUxYzhhNGRjOWUyOTMyNzY4M2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Fyn-xbT8o62xnJ1HTTHY3u1-_VmtyoQ7pK10OyepXpI) yes.But new problem as follow: ![Uploading error2.png…]() {detail: 'Ollama WebUI: Server Connection Error', message: "HTTPConnectionPool(host='host.docker.internal', po…ker.internal timed out. (connect timeout=None)'))"} detail : "Ollama WebUI: Server Connection Error" message : "HTTPConnectionPool(host='host.docker.internal', port=11434): Max retries exceeded with url: /api/tags (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fd3a11aef10>, 'Connection to host.docker.internal timed out. (connect timeout=None)'))"
Author
Owner

@tjbck commented on GitHub (Dec 27, 2023):

You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu

Keep us updated!

@tjbck commented on GitHub (Dec 27, 2023): You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu Keep us updated!
Author
Owner

@heweapon commented on GitHub (Dec 27, 2023):

You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu

Keep us updated!

OK.Thank you

@heweapon commented on GitHub (Dec 27, 2023): > You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu > > Keep us updated! OK.Thank you
Author
Owner

@heweapon commented on GitHub (Dec 27, 2023):

You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu

Keep us updated!

Sorry. I still can't solve my problem. I deployed it on the server, not localhost.

@heweapon commented on GitHub (Dec 27, 2023): > You might want to try this method: https://github.com/ollama-webui/ollama-webui/blob/main/TROUBLESHOOTING.md#running-ollama-webui-as-a-container-on-wsl-ubuntu > > Keep us updated! Sorry. I still can't solve my problem. I deployed it on the server, not localhost.
Author
Owner

@tjbck commented on GitHub (Dec 27, 2023):

Is the webui running on the same server as your ollama instance?

@tjbck commented on GitHub (Dec 27, 2023): Is the webui running on the same server as your ollama instance?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#125