cors block added

This commit is contained in:
nquidox 2025-09-09 23:18:17 +03:00
parent a6ed067478
commit c657a3a7da

View file

@ -1,6 +1,7 @@
package router
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
swaggerFiles "github.com/swaggo/files"
@ -8,6 +9,7 @@ import (
"merch-parser-api/internal/interfaces"
"merch-parser-api/internal/shared"
"net/http"
"time"
)
type router struct {
@ -38,6 +40,15 @@ func NewRouter(deps Deps) interfaces.Router {
}
}
engine.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:5173"},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
}))
return &router{
apiPrefix: deps.ApiPrefix,
engine: engine,