tambahan cors

This commit is contained in:
2025-06-18 08:20:41 +07:00
parent 7923dced22
commit a1d2d36bce
3 changed files with 50 additions and 15 deletions
+8 -2
View File
@@ -2,15 +2,21 @@ package server
import (
"api-lis/pkg/middleware"
"net/http"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"net/http"
dataretribusiHandler "api-lis/pkg/handlers/data_retribusi"
)
func (s *Server) RegisterRoutes() http.Handler {
r := gin.Default()
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"}, // or specific domains like "http://example.com"
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type"},
AllowCredentials: true,
}))
r.GET("/", s.HelloWorldHandler)
r.GET("/health", s.healthHandler)