cors block added
This commit is contained in:
parent
a6ed067478
commit
c657a3a7da
1 changed files with 11 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/gin-contrib/cors"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
swaggerFiles "github.com/swaggo/files"
|
swaggerFiles "github.com/swaggo/files"
|
||||||
|
|
@ -8,6 +9,7 @@ import (
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
"merch-parser-api/internal/shared"
|
"merch-parser-api/internal/shared"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type router struct {
|
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{
|
return &router{
|
||||||
apiPrefix: deps.ApiPrefix,
|
apiPrefix: deps.ApiPrefix,
|
||||||
engine: engine,
|
engine: engine,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue