Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/10-production-boilerplate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ DATABASE_DSN=./data/app.db
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRATION=24h

# CORS
# CORS (comma-separated allowed origins; "*" allows any origin)
CORS_ORIGINS=http://localhost:3000,http://localhost:8080
```

Expand Down
4 changes: 3 additions & 1 deletion examples/10-production-boilerplate/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ func main() {
// Global middleware
router.Use(middleware.Logger())
router.Use(middleware.Recovery())
router.Use(middleware.CORS())
router.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: cfg.CORSOrigins,
}))

// Health check endpoint
router.Handle("GET", "/health", func(c *fursy.Context) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Config struct {
JWTSecret []byte
JWTExpiration time.Duration

// CORS settings
CORSOrigins []string
// CORS settings: comma-separated list of allowed origins.
CORSOrigins string
}

// Load loads configuration from environment variables.
Expand All @@ -38,7 +38,7 @@ func Load() *Config {
DatabaseDSN: getEnv("DATABASE_DSN", "./data/app.db"),
JWTSecret: []byte(getEnv("JWT_SECRET", "your-super-secret-jwt-key-change-in-production")),
JWTExpiration: jwtExpiration,
CORSOrigins: []string{getEnv("CORS_ORIGINS", "http://localhost:3000,http://localhost:8080")},
CORSOrigins: getEnv("CORS_ORIGINS", "http://localhost:3000,http://localhost:8080"),
}
}

Expand Down