Skip to content

Commit

Permalink
API app/browser access (ollama#4879)
Browse files Browse the repository at this point in the history
* API app/browser access

* Add tauri (resolves ollama#2291, ollama#4791, ollama#3799, ollama#4388)
  • Loading branch information
royjhan authored Jun 6, 2024
1 parent 4bf1da4 commit 1a29e9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions envconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ func LoadConfig() {
)
}

AllowOrigins = append(AllowOrigins,
"app://*",
"file://*",
"tauri://*",
)

maxRunners := clean("OLLAMA_MAX_LOADED_MODELS")
if maxRunners != "" {
m, err := strconv.Atoi(maxRunners)
Expand Down
4 changes: 4 additions & 0 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,10 @@ func (s *Server) GenerateRoutes() http.Handler {
config.AllowWildcard = true
config.AllowBrowserExtensions = true
config.AllowHeaders = []string{"Authorization", "Content-Type", "User-Agent", "Accept", "X-Requested-With"}
openAIProperties := []string{"lang", "package-version", "os", "arch", "runtime", "runtime-version", "async"}
for _, prop := range openAIProperties {
config.AllowHeaders = append(config.AllowHeaders, "x-stainless-"+prop)
}
config.AllowOrigins = envconfig.AllowOrigins

r := gin.Default()
Expand Down

0 comments on commit 1a29e9a

Please sign in to comment.