Skip to content

Commit

Permalink
Add CORS to magic
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani authored Oct 1, 2024
1 parent 4a0fc00 commit 6fa1508
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go/server_magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"

"github.com/gin-gonic/gin"
"github.com/gin-contrib/cors"
"github.com/joho/godotenv"
_ "github.com/mattn/go-sqlite3"
"github.com/metrico/pasticca/paste"
Expand Down Expand Up @@ -49,6 +50,17 @@ func main() {

router := gin.Default()

// CORS configuration
config := cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "HEAD"},
AllowHeaders: []string{"*"},
ExposeHeaders: []string{},
MaxAge: 3000,
}

router.Use(cors.New(config))

router.GET("/*path", server.handleRequest)
router.HEAD("/*path", server.handleRequest)
router.POST("/*path", server.handlePostRequest)
Expand Down

0 comments on commit 6fa1508

Please sign in to comment.