Skip to content

fix: add Origin header for Ollama requests to fix Forbidden error#2178

Merged
yujonglee merged 1 commit intomainfrom
devin/1765249518-fix-ollama-forbidden
Dec 9, 2025
Merged

fix: add Origin header for Ollama requests to fix Forbidden error#2178
yujonglee merged 1 commit intomainfrom
devin/1765249518-fix-ollama-forbidden

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

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 tauriFetch client (from @tauri-apps/plugin-http) doesn't set an Origin header by default, while the browser's native fetch (used by ollama/browser for model listing) does. This explains why model listing works but chat completions fail.

Fix: Add a dedicated case "ollama": in createLanguageModel that wraps tauriFetch with an explicit Origin: http://localhost header, which is in Ollama's default allowed origins list.

Review & Testing Checklist for Human

  • Test with Ollama locally: Configure Hyprnote to use Ollama with default OLLAMA_ORIGINS settings (not *) and verify chat completions work without "Forbidden" errors
  • Verify the Origin value: Confirm http://localhost is correct for Ollama's default allowed origins (may need http://127.0.0.1 instead depending on Ollama version)
  • Test model listing still works: Ensure the existing model listing functionality via ollama/browser is unaffected

Notes

  • The hardcoded http://localhost Origin value is based on Ollama's documented default allowed origins. If users have Ollama bound to a different interface, they may still need to configure OLLAMA_ORIGINS.
  • This change only affects the Ollama provider; other providers (LM Studio, custom) continue using the default tauriFetch without Origin header modification.

Link to Devin run: https://app.devin.ai/sessions/49d4440bff114df891854c314c720cb1
Requested by: yujonglee (@yujonglee)

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>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 9, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 9, 2025

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit 5c29d0e
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/693792c2406d7400084acaca
😎 Deploy Preview https://deploy-preview-2178--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 9, 2025

Deploy Preview for hyprnote-storybook ready!

Name Link
🔨 Latest commit 5c29d0e
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/693792c2a7dc610008378911
😎 Deploy Preview https://deploy-preview-2178--hyprnote-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@yujonglee yujonglee merged commit 3e3c1ab into main Dec 9, 2025
16 of 17 checks passed
@yujonglee yujonglee deleted the devin/1765249518-fix-ollama-forbidden branch December 9, 2025 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama is forbidden

1 participant