From 385f3cbc0f79d909ee424de7fbf94555c36eb85d Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 3 Sep 2024 18:31:30 +0200 Subject: [PATCH] feat: cors --- apiService.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apiService.go b/apiService.go index 4d7bf43..b472140 100644 --- a/apiService.go +++ b/apiService.go @@ -12,6 +12,14 @@ import ( func APIService(c ClustersToRun) { runCluster := func(mode ConnectionMode, host string, hostSSL string, key string, crt string) { router := gin.Default() + router.Use(cors.New(cors.Config{ + AllowOrigins: []string{"https://explorer.atlasnet.staratlas.cloud"}, + AllowMethods: []string{"GET"}, + AllowHeaders: []string{"Origin"}, + ExposeHeaders: []string{"Content-Length"}, + AllowCredentials: true, + MaxAge: 12 * time.Hour, + })) router.GET("/:cluster/latest", getLatest) router.GET("/:cluster/last6hours", timeout.New(timeout.WithTimeout(10*time.Second), timeout.WithHandler(last6hours))) router.GET("/:cluster/last6hours/nocomputeprice", timeout.New(timeout.WithTimeout(10*time.Second), timeout.WithHandler(last6hoursNoPrice)))