this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

back(cors): add cors middleware

Clément 2842e900 420ce2c6

+21 -12
+1
backend/go.mod
··· 5 5 require ( 6 6 github.com/glebarez/go-sqlite v1.22.0 7 7 github.com/go-chi/chi/v5 v5.2.4 8 + github.com/go-chi/cors v1.2.2 8 9 github.com/go-sqlx/sqlx v1.3.8 9 10 github.com/gofrs/uuid v4.4.0+incompatible 10 11 github.com/syumai/workers v0.31.0
+2
backend/go.sum
··· 115 115 github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= 116 116 github.com/go-chi/chi/v5 v5.2.4 h1:WtFKPHwlywe8Srng8j2BhOD9312j9cGUxG1SP4V2cR4= 117 117 github.com/go-chi/chi/v5 v5.2.4/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0= 118 + github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE= 119 + github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= 118 120 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 119 121 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 120 122 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+17
backend/internal/middlewares/cors.go
··· 1 + package middlewares 2 + 3 + import ( 4 + "net/http" 5 + 6 + "github.com/go-chi/cors" 7 + ) 8 + 9 + func CORS(next http.Handler) http.Handler { 10 + return cors.Handler(cors.Options{ 11 + AllowedOrigins: []string{"http://localhost:5173", "https://api.uiua.online"}, 12 + AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, 13 + AllowedHeaders: []string{"Accept", "Cookie", "Content-Type"}, 14 + AllowCredentials: true, 15 + MaxAge: 300, // Maximum value not ignored by any of major browsers 16 + })(next) 17 + }
+1
backend/internal/router/router.go
··· 21 21 r := chi.NewRouter() 22 22 r.Use(chimiddleware.Logger) 23 23 r.Use(chimiddleware.Recoverer) 24 + r.Use(middlewares.CORS) 24 25 25 26 r.Get("/", handlers.Health) 26 27
-12
backend/wrangler.jsonc
··· 17 17 "migrations_dir": "migrations", 18 18 }, 19 19 ], 20 - "env": { 21 - "dev": { 22 - "d1_databases": [ 23 - { 24 - "binding": "DB", 25 - "database_name": "uiua-database-dev", 26 - "database_id": "459723c8-7da1-44a3-86ce-c23706cb14f5", 27 - "migrations_dir": "migrations", 28 - }, 29 - ], 30 - }, 31 - }, 32 20 }