Skip to content

Commit

Permalink
fix: Setup cors middleware in the start of init
Browse files Browse the repository at this point in the history
  • Loading branch information
BasedDepartment1 committed Oct 13, 2023
1 parent c159ff4 commit b65c660
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func HandleHello(c *gin.Context) error {

func Init(app application.App) error {
fmt.Printf("Got key: %s", config.Section.Key)
app.Router().GET("/hello", application.AsGinHandler(HandleHello))

corsConfig := cors.DefaultConfig()
if config.Cors.AllowOrigin == "*" {
Expand All @@ -55,6 +54,8 @@ func Init(app application.App) error {
}
app.Router().Use(cors.New(corsConfig))

app.Router().GET("/hello", application.AsGinHandler(HandleHello))

// TODO(svayp11): Create type for database config and use env secrets
connConfig := pgx.ConnConfig{
Host: config.DB.Host,
Expand Down

0 comments on commit b65c660

Please sign in to comment.