add cors policy
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user