Skip to content

Commit

Permalink
Remove CORS.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang committed Aug 15, 2024
1 parent d3b1c1f commit ba1c690
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package server

import (
"context"
"os"
"registry-backend/config"
generated "registry-backend/drip"
"registry-backend/ent"
Expand Down Expand Up @@ -42,35 +41,6 @@ func (s *Server) Start() error {
e := echo.New()
e.HideBanner = true
e.Use(drip_middleware.TracingMiddleware)
//e.Use(middleware.Logger()) // Useful for debugging
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowMethods: []string{echo.GET, echo.PUT, echo.POST, echo.DELETE},
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept, echo.HeaderAuthorization},
AllowCredentials: true,
AllowOriginFunc: func(origin string) (bool, error) {
// Allow all GET requests
if strings.EqualFold(echo.GET, echo.HeaderXHTTPMethodOverride) {
return true, nil
}
allowedOrigins := []string{
".comfyci.org", // Any subdomain of comfyci.org
os.Getenv("CORS_ORIGIN"), // Environment-specific allowed origin
".comfyregistry.org",
".comfy.org",
}

for _, allowed := range allowedOrigins {
if strings.HasSuffix(origin, allowed) || origin == allowed {
log.Debug().Msg("[CORSWithConfig] Allowing origin " + origin)
return true, nil
}
}

log.Debug().Msg("[CORSWithConfig] Rejecting origin " + origin)
return false, nil
},
}))

e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
LogURI: true,
LogStatus: true,
Expand Down

0 comments on commit ba1c690

Please sign in to comment.