fix: add Origin header for Ollama requests to fix Forbidden error#2178
Merged
fix: add Origin header for Ollama requests to fix Forbidden error#2178
Conversation
Ollama's CORS check rejects requests without a recognized Origin header. The tauriFetch client doesn't set an Origin header by default, causing 'Forbidden' errors when making chat completion requests to Ollama. This adds a dedicated case for Ollama that wraps tauriFetch with an Origin header set to 'http://localhost', which is in Ollama's default allowed origins list. Fixes #2123 Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2123 - Ollama returning "Forbidden" errors when making chat completion requests from Hyprnote.
Root cause: Ollama's CORS check rejects requests without a recognized Origin header. The
tauriFetchclient (from@tauri-apps/plugin-http) doesn't set an Origin header by default, while the browser's nativefetch(used byollama/browserfor model listing) does. This explains why model listing works but chat completions fail.Fix: Add a dedicated
case "ollama":increateLanguageModelthat wrapstauriFetchwith an explicitOrigin: http://localhostheader, which is in Ollama's default allowed origins list.Review & Testing Checklist for Human
OLLAMA_ORIGINSsettings (not*) and verify chat completions work without "Forbidden" errorshttp://localhostis correct for Ollama's default allowed origins (may needhttp://127.0.0.1instead depending on Ollama version)ollama/browseris unaffectedNotes
http://localhostOrigin value is based on Ollama's documented default allowed origins. If users have Ollama bound to a different interface, they may still need to configureOLLAMA_ORIGINS.tauriFetchwithout Origin header modification.Link to Devin run: https://app.devin.ai/sessions/49d4440bff114df891854c314c720cb1
Requested by: yujonglee (@yujonglee)