mirror of
https://github.com/ollama/ollama.git
synced 2025-11-11 23:17:43 +01:00
pass flags to serve to allow setting allowed-origins + host and port
* resolves: https://github.com/jmorganca/ollama/issues/300 and https://github.com/jmorganca/ollama/issues/282 * example usage: ``` ollama serve --port 9999 --allowed-origins "http://foo.example.com,http://192.0.0.1" ```
This commit is contained in:
@@ -301,11 +301,11 @@ func CopyModelHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func Serve(ln net.Listener) error {
|
||||
func Serve(ln net.Listener, extraOrigins []string) error {
|
||||
config := cors.DefaultConfig()
|
||||
config.AllowWildcard = true
|
||||
// only allow http/https from localhost
|
||||
config.AllowOrigins = []string{
|
||||
allowedOrigins := []string{
|
||||
"http://localhost",
|
||||
"http://localhost:*",
|
||||
"https://localhost",
|
||||
@@ -315,6 +315,8 @@ func Serve(ln net.Listener) error {
|
||||
"https://127.0.0.1",
|
||||
"https://127.0.0.1:*",
|
||||
}
|
||||
allowedOrigins = append(allowedOrigins, extraOrigins...)
|
||||
config.AllowOrigins = allowedOrigins
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(cors.New(config))
|
||||
|
||||
Reference in New Issue
Block a user