[GH-ISSUE #3983] CORS not working in Safari (but does in Chrome) #48977

Closed
opened 2026-04-28 10:25:14 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @finn753 on GitHub (Apr 27, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3983

Originally assigned to: @BruceMacD on GitHub.

What is the issue?

I can't make API requests from Safari.
I've enabled all origins "*" and it perfectly works in Chrome, but Safari just throws CORS errors.
I've tried with the ollama/browser npm package and a manual fetch request, to make sure it's not the problem.
Both are failing

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.1.32

Originally created by @finn753 on GitHub (Apr 27, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3983 Originally assigned to: @BruceMacD on GitHub. ### What is the issue? I can't make API requests from Safari. I've enabled all origins "*" and it perfectly works in Chrome, but Safari just throws CORS errors. I've tried with the ollama/browser npm package and a manual fetch request, to make sure it's not the problem. Both are failing ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.1.32
GiteaMirror added the bug label 2026-04-28 10:25:14 -05:00
Author
Owner

@BruceMacD commented on GitHub (May 1, 2024):

Hi @finn753, thanks for opening the issue. Safari has some stricter CORs policies than Chrome does. Is there any specific CORs error in the safari console? That will help narrow this one down a bit, a quick Safari CORs test worked for my specific setup.

<!-- gh-comment-id:2088963882 --> @BruceMacD commented on GitHub (May 1, 2024): Hi @finn753, thanks for opening the issue. Safari has some stricter CORs policies than Chrome does. Is there any specific CORs error in the safari console? That will help narrow this one down a bit, a quick Safari CORs test worked for my specific setup.
Author
Owner

@jzevin commented on GitHub (May 5, 2024):

@BruceMacD I was going to post the issue, so I had done a bit of research as I don't know go but the following may help:

06164911dd/llm/ext_server/server.cpp (L2841)
I think Safari does not accept the wildcard in Access-Control-Allow-Headers when credentials are included. Consequently, requests that explicitly set the User-Agent header are blocked due to CORS policy violations.

Proposed Solution:
Replace the wildcard in the Access-Control-Allow-Headers with an explicit list of headers. For example:

res.set_header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, User-Agent");

Impact:
This issue prevents the application from performing authorized cross-origin requests where custom headers, particularly User-Agent, are necessary.

<!-- gh-comment-id:2094977162 --> @jzevin commented on GitHub (May 5, 2024): @BruceMacD I was going to post the issue, so I had done a bit of research as I don't know go but the following may help: https://github.com/ollama/ollama/blob/06164911dd7d79a87330a3249a96c56890332ad0/llm/ext_server/server.cpp#L2841 I think Safari does not accept the wildcard in Access-Control-Allow-Headers when credentials are included. Consequently, requests that explicitly set the User-Agent header are blocked due to CORS policy violations. Proposed Solution: Replace the wildcard in the Access-Control-Allow-Headers with an explicit list of headers. For example: ```res.set_header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, User-Agent");``` Impact: This issue prevents the application from performing authorized cross-origin requests where custom headers, particularly User-Agent, are necessary.
Author
Owner

@BruceMacD commented on GitHub (May 7, 2024):

Thanks for the insights @jzevin, I was able to reproduce and add a couple more headers to #4086 that will fix this.

<!-- gh-comment-id:2097144848 --> @BruceMacD commented on GitHub (May 7, 2024): Thanks for the insights @jzevin, I was able to reproduce and add a couple more headers to #4086 that will fix this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#48977