From 18da8515667f1eee7b6b19fbf0dc6f85cbea792a Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Tue, 2 May 2023 21:37:10 +0300 Subject: add cors origin for steamcommunity --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index aae2a18..4f40ba9 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "log" "os" + "github.com/gin-gonic/contrib/cors" "github.com/gin-gonic/gin" "github.com/joho/godotenv" "github.com/pektezol/leastportals/backend/database" @@ -19,8 +20,8 @@ import ( // @license.name GNU General Public License, Version 2 // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -// @host lp.ardapektezol.com/api -// @BasePath /v1 +// @host lp.ardapektezol.com/api +// @BasePath /v1 func main() { if os.Getenv("ENV") == "PROD" { gin.SetMode(gin.ReleaseMode) @@ -30,6 +31,9 @@ func main() { log.Fatal("Error loading .env file") } router := gin.Default() + config := cors.DefaultConfig() + config.AllowedOrigins = []string{"https://steamcommunity.com"} + router.Use(cors.New(config)) database.ConnectDB() // For frontend static serving - only for local debug // router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) -- cgit v1.2.3