fix: trim quotes on OLLAMA_ORIGINS
This commit is contained in:
parent
461ad25015
commit
af8a8a6b59
1 changed files with 4 additions and 6 deletions
|
@ -1013,16 +1013,14 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GenerateRoutes() http.Handler {
|
func (s *Server) GenerateRoutes() http.Handler {
|
||||||
var origins []string
|
|
||||||
if o := os.Getenv("OLLAMA_ORIGINS"); o != "" {
|
|
||||||
origins = strings.Split(o, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
config := cors.DefaultConfig()
|
config := cors.DefaultConfig()
|
||||||
config.AllowWildcard = true
|
config.AllowWildcard = true
|
||||||
config.AllowBrowserExtensions = 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 {
|
for _, allowOrigin := range defaultAllowOrigins {
|
||||||
config.AllowOrigins = append(config.AllowOrigins,
|
config.AllowOrigins = append(config.AllowOrigins,
|
||||||
fmt.Sprintf("http://%s", allowOrigin),
|
fmt.Sprintf("http://%s", allowOrigin),
|
||||||
|
|
Loading…
Reference in a new issue