[GH-ISSUE #3799] Enable CORS for file:/// URLs #28105

Closed
opened 2026-04-22 05:56:02 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jmorganca on GitHub (Apr 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3799

Originally assigned to: @royjhan on GitHub.

This would help with local development html & javascript apps for Ollama. Important to validate the security risks of this.

Originally created by @jmorganca on GitHub (Apr 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3799 Originally assigned to: @royjhan on GitHub. This would help with local development html & javascript apps for Ollama. Important to validate the security risks of this.
GiteaMirror added the feature request label 2026-04-22 05:56:02 -05:00
Author
Owner

@drazdra commented on GitHub (Apr 21, 2024):

as i said at discord, the best way is to add basic "web-server" functionality to ollama.

  1. made a single predefined folder in Ollama which will have the files served to users.
  2. serve these files through 127.0.0.1:11434/index.html (or other pages)
  3. validate file names to allow only /^[-_a-z0-9]{1,32}.[a-z0-9]{1,5}$/i so there is nothing like "../../" no special chars, etc. test the served file is a real file and not a link before serving it.
  4. spit the content of file to the user.

that's it. now the CORS protection is intact, HOST protection is intact and installing a web UI is as easy as putting it into the "web folder" of ollama.

ideal, super simple and easy to implement, yet still secure. connections are still received only on a configured HOST. Malicious sites can't access local Ollama because their Host is different from the Host of Ollama server and cors will block these. Ideal.

<!-- gh-comment-id:2068126271 --> @drazdra commented on GitHub (Apr 21, 2024): as i said at discord, the best way is to add basic "web-server" functionality to ollama. 1. made a single predefined folder in Ollama which will have the files served to users. 2. serve these files through 127.0.0.1:11434/index.html (or other pages) 3. validate file names to allow only /^[-_a-z0-9]{1,32}\.[a-z0-9]{1,5}$/i so there is nothing like "../../" no special chars, etc. test the served file is a real file and not a link before serving it. 4. spit the content of file to the user. that's it. now the CORS protection is intact, HOST protection is intact and installing a web UI is as easy as putting it into the "web folder" of ollama. ideal, super simple and easy to implement, yet still secure. connections are still received only on a configured HOST. Malicious sites can't access local Ollama because their Host is different from the Host of Ollama server and cors will block these. Ideal.
Author
Owner

@airtonix commented on GitHub (May 12, 2024):

https://github.com/ollama/ollama/issues/4385

<!-- gh-comment-id:2106407161 --> @airtonix commented on GitHub (May 12, 2024): https://github.com/ollama/ollama/issues/4385
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#28105