add cors policy

This commit is contained in:
2025-03-20 10:04:21 +07:00
parent f6a2cf3a5b
commit cdfd8da59d
3 changed files with 10 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/coder/websocket"
"github.com/gin-contrib/cors"
patientHandler "template_blueprint/pkg/handlers/patient"
)
@@ -42,6 +43,12 @@ func (s *Server) RegisterRoutes() http.Handler {
patient.POST("/insertpatient", patientHandler.InsertPatient)
patient.GET("/getallpatient", patientHandler.GetAllPatient)
}
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"}, // or specific domains like "http://example.com"
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Type"},
AllowCredentials: true,
}))
return r
}