Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

fix: trim quotes on OLLAMA_ORIGINS

Michael Yangaf8a8a6b5908
diff --git a/server/routes.go b/server/routes.go
index 5582f3a15..77eb77ea5 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -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),