Skip to content

Commit 3c2fa9f

Browse files
update cors policy
1 parent 098b3b9 commit 3c2fa9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/handlers/server.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ func NewServer(db *gorm.DB, config *config.Config) *Server {
4040
func (s *Server) setupRoutes() {
4141
s.router.Use(gin.Recovery())
4242

43-
s.router.Use(cors.Default())
43+
s.router.Use(cors.New(cors.Config{
44+
AllowOrigins: []string{"http://localhost:3000", "https://forgotten.onrender.com"},
45+
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
46+
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"},
47+
ExposeHeaders: []string{"Content-Length"},
48+
AllowCredentials: true,
49+
MaxAge: 12 * time.Hour,
50+
}))
4451
s.router.Use(middleware.LoggingMiddleware())
4552
s.router.Use(middleware.MetricsMiddleware())
4653
_ = s.router.SetTrustedProxies(nil)

0 commit comments

Comments
 (0)