fix: CORS Origin

This commit is contained in:
2025-11-19 18:38:17 -07:00
parent 6a9948b4fe
commit 0100b8b6c5

View File

@@ -2,13 +2,14 @@ package corsmiddleware
import ( import (
"log" "log"
"os"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func CORSMiddleware(c *gin.Context) { func CORSMiddleware(c *gin.Context) {
log.Printf("%s", c.Request.Method) log.Printf("%s", c.Request.Method)
c.Writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:3000") c.Writer.Header().Set("Access-Control-Allow-Origin", os.Getenv("ALLOWED_ORIGIN"))
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, DELETE") c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, DELETE")