Skip to content

Commit

Permalink
Merge pull request ollama#3379 from ollama/mxyng/origins
Browse files Browse the repository at this point in the history
fix: trim quotes on OLLAMA_ORIGINS
  • Loading branch information
mxyng authored Mar 28, 2024
2 parents 9c6a254 + af8a8a6 commit 035b274
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,16 +1013,14 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc {
}

func (s *Server) GenerateRoutes() http.Handler {
var origins []string
if o := os.Getenv("OLLAMA_ORIGINS"); o != "" {
origins = strings.Split(o, ",")
}

config := cors.DefaultConfig()
config.AllowWildcard = true
config.AllowBrowserExtensions = true

config.AllowOrigins = origins
if allowedOrigins := strings.Trim(os.Getenv("OLLAMA_ORIGINS"), "\"'"); allowedOrigins != "" {
config.AllowOrigins = strings.Split(allowedOrigins, ",")
}

for _, allowOrigin := range defaultAllowOrigins {
config.AllowOrigins = append(config.AllowOrigins,
fmt.Sprintf("http://%s", allowOrigin),
Expand Down

0 comments on commit 035b274

Please sign in to comment.