diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-05-02 21:41:46 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-05-02 21:41:46 +0300 |
| commit | 0378d3c100ba130798b68f4fc29b42d225d45fcc (patch) | |
| tree | 0a22932b6654d42e03ebf4723c805a992ce107b9 | |
| parent | add cors origin for steamcommunity (diff) | |
| download | lphub-0378d3c100ba130798b68f4fc29b42d225d45fcc.tar.gz lphub-0378d3c100ba130798b68f4fc29b42d225d45fcc.tar.bz2 lphub-0378d3c100ba130798b68f4fc29b42d225d45fcc.zip | |
fix: cors origin for steamcommunity
| -rw-r--r-- | main.go | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -20,8 +20,8 @@ import ( | |||
| 20 | // @license.name GNU General Public License, Version 2 | 20 | // @license.name GNU General Public License, Version 2 |
| 21 | // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 21 | // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 22 | 22 | ||
| 23 | // @host lp.ardapektezol.com/api | 23 | // @host lp.ardapektezol.com/api |
| 24 | // @BasePath /v1 | 24 | // @BasePath /v1 |
| 25 | func main() { | 25 | func main() { |
| 26 | if os.Getenv("ENV") == "PROD" { | 26 | if os.Getenv("ENV") == "PROD" { |
| 27 | gin.SetMode(gin.ReleaseMode) | 27 | gin.SetMode(gin.ReleaseMode) |
| @@ -31,9 +31,9 @@ func main() { | |||
| 31 | log.Fatal("Error loading .env file") | 31 | log.Fatal("Error loading .env file") |
| 32 | } | 32 | } |
| 33 | router := gin.Default() | 33 | router := gin.Default() |
| 34 | config := cors.DefaultConfig() | 34 | router.Use(cors.New(cors.Config{ |
| 35 | config.AllowedOrigins = []string{"https://steamcommunity.com"} | 35 | AllowedOrigins: []string{"https://steamcommunity.com"}, |
| 36 | router.Use(cors.New(config)) | 36 | })) |
| 37 | database.ConnectDB() | 37 | database.ConnectDB() |
| 38 | // For frontend static serving - only for local debug | 38 | // For frontend static serving - only for local debug |
| 39 | // router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) | 39 | // router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) |