Skip to content

Commit

Permalink
enable cors in both dev and prod (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
3DRX authored Sep 10, 2024
1 parent 80b7db5 commit 340864b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ import (

func main() {
args := os.Args[1:]
isProd := false
config := cors.DefaultConfig()
logger := logger.GetInstance()
if len(args) != 0 && args[0] == "prod" {
gin.SetMode(gin.ReleaseMode)
isProd = true
gin.DisableConsoleColor()
} else {
fmt.Println("Running in dev mode, use 'tcctl prod' to run in release mode")
config.AllowOrigins = []string{"http://localhost:5173"}
}
r := gin.Default()
if !isProd {
r.Use(cors.New(config))
}
r.Use(cors.New(config))
r.Use(sloggin.New(logger))
r.Use(gin.Recovery())

Expand Down

0 comments on commit 340864b

Please sign in to comment.