[GH-ISSUE #8342] CORS error x-stainless-helper-method #31108

Closed
opened 2026-04-22 11:16:05 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @isamu on GitHub (Jan 8, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8342

What is the issue?

I am making requests to a local instance of Ollama using the OpenAI npm package from browser. When I add stream: true to OpenAI npm, I encounter the following CORS error:

Access to fetch at 'http://127.0.0.1:11434/v1/chat/completions' from origin 'http://localhost:5174' has been blocked by CORS policy: Request header field x-stainless-helper-method is not allowed by Access-Control-Allow-Headers in preflight response.

When adding stream: true to OpenAI, the following HTTP header is included:

x-stainless-helper-method: stream

This header causes a CORS error. Similar to issue #6910, preflight header is necessary.

Additionally, by inspecting OpenAI's npm package, the following headers may also be added:

  • X-Stainless-Poll-Helper
  • X-Stainless-Custom-Poll-Interval

These headers might require handling in your setup to avoid similar CORS-related issues.

Thanks.

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.5.4

Originally created by @isamu on GitHub (Jan 8, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8342 ### What is the issue? I am making requests to a local instance of Ollama using the OpenAI npm package from browser. When I add `stream: true` to OpenAI npm, I encounter the following CORS error: ``` Access to fetch at 'http://127.0.0.1:11434/v1/chat/completions' from origin 'http://localhost:5174' has been blocked by CORS policy: Request header field x-stainless-helper-method is not allowed by Access-Control-Allow-Headers in preflight response. ``` When adding `stream: true` to OpenAI, the following HTTP header is included: ``` x-stainless-helper-method: stream ``` This header causes a CORS error. Similar to issue #6910, preflight header is necessary. Additionally, by inspecting OpenAI's npm package, the following headers may also be added: - `X-Stainless-Poll-Helper` - `X-Stainless-Custom-Poll-Interval` These headers might require handling in your setup to avoid similar CORS-related issues. Thanks. ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.5.4
GiteaMirror added the bug label 2026-04-22 11:16:05 -05:00
Author
Owner

@rick-github commented on GitHub (Jan 17, 2025):

Has this been resolved by the merging of #8343?

<!-- gh-comment-id:2597261353 --> @rick-github commented on GitHub (Jan 17, 2025): Has this been resolved by the merging of #8343?
Author
Owner

@DangNhutNguyen commented on GitHub (Jan 17, 2025):

It looks like the x-stainless-helper-method header is being blocked by CORS on the Ollama server. You may need to update the server's CORS settings to allow this header or set up a backend proxy to bypass the restriction.

<!-- gh-comment-id:2597268877 --> @DangNhutNguyen commented on GitHub (Jan 17, 2025): It looks like the `x-stainless-helper-method` header is being blocked by CORS on the Ollama server. You may need to update the server's CORS settings to allow this header or set up a backend proxy to bypass the restriction.
Author
Owner

@isamu commented on GitHub (Jan 17, 2025):

It has been fixed and merged.
The fix is ​​included in 0.5.5.
Please try the latest version.

<!-- gh-comment-id:2597274820 --> @isamu commented on GitHub (Jan 17, 2025): It has been fixed and merged. The fix is ​​included in 0.5.5. Please try the latest version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#31108