server: send 405 instead of 404 for unallowed methods (#10275)

Fixes: #5483
This commit is contained in:
Devon Rifkin 2025-05-06 14:45:37 -07:00 committed by GitHub
parent 92ce438de0
commit 4090aca97b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -1170,6 +1170,7 @@ func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error) {
corsConfig.AllowOrigins = envconfig.AllowedOrigins()
r := gin.Default()
r.HandleMethodNotAllowed = true
r.Use(
cors.New(corsConfig),
allowedHostsMiddleware(s.addr),