more boilerplate and dev environment

This commit is contained in:
2026-07-16 16:04:48 -07:00
parent ea34be4e1b
commit a06f21a5c2
27 changed files with 670 additions and 27 deletions
+17
View File
@@ -3,7 +3,10 @@ package main
import (
"log"
"net/http"
"os"
"strings"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
@@ -16,6 +19,20 @@ func main() {
router := gin.Default()
// Configure CORS. In production, set CORS_ALLOWED_ORIGINS to your public domain.
allowedOrigins := []string{"http://localhost:5173"}
if envOrigins := os.Getenv("CORS_ALLOWED_ORIGINS"); envOrigins != "" {
allowedOrigins = strings.Split(envOrigins, ",")
}
router.Use(cors.New(cors.Config{
AllowOrigins: allowedOrigins,
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
MaxAge: 12 * 60 * 60,
}))
router.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",