This commit is contained in:
2026-08-22 20:14:20 +02:00
parent 9f1424447f
commit 2cd7abb403
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -163,7 +163,8 @@ func withCORS(allowedOrigin string) gin.HandlerFunc {
func originAllowed(origin, configured string) bool { func originAllowed(origin, configured string) bool {
for _, allowed := range strings.Split(configured, ",") { for _, allowed := range strings.Split(configured, ",") {
if strings.TrimSpace(allowed) == "*" || strings.TrimSpace(allowed) == origin { allowed = strings.TrimRight(strings.TrimSpace(allowed), "/")
if allowed == "*" || allowed == origin {
return true return true
} }
} }
+1 -1
View File
@@ -36,7 +36,7 @@ func Load() Config {
return Config{ return Config{
DBDriver: envOrDefault("DB_DRIVER", "postgres"), DBDriver: envOrDefault("DB_DRIVER", "postgres"),
Port: envOrDefault("PORT", "8080"), Port: envOrDefault("PORT", "8080"),
APIURL: envOrDefault("API_URL", ""), APIURL: strings.TrimRight(envOrDefault("API_URL", ""), "/"),
DatabaseURL: envOrDefault("DATABASE_URL", "postgres://surprise:surprise_dev_password@localhost:5432/surprise?sslmode=disable"), DatabaseURL: envOrDefault("DATABASE_URL", "postgres://surprise:surprise_dev_password@localhost:5432/surprise?sslmode=disable"),
SQLitePath: envOrDefault("SQLITE_PATH", "./data/surprise.db"), SQLitePath: envOrDefault("SQLITE_PATH", "./data/surprise.db"),
CORSOrigin: envOrDefault("CORS_ORIGIN", "http://localhost:5173,http://127.0.0.1:5173"), CORSOrigin: envOrDefault("CORS_ORIGIN", "http://localhost:5173,http://127.0.0.1:5173"),