Files
steam_analyzer/pkg/server/utils.go
2026-01-17 22:45:02 +03:00

28 lines
527 B
Go

package server
import (
"net/http"
"github.com/rs/cors"
)
func configureCORSFor(handler http.Handler, origins []string) http.Handler {
ch := cors.New(cors.Options{
// # http://mywebsite-domain.com/ is configured in hosts (localhost:80 alias)
AllowedOrigins: origins,
AllowedMethods: []string{
http.MethodPost,
http.MethodGet,
http.MethodPut,
http.MethodDelete,
// http.MethodOptions,
},
OptionsPassthrough: false,
AllowCredentials: true,
// Debug: true,
})
return ch.Handler(handler)
}