Unofficial CORS middleware for the gleam_http
library.
gleam add gleam_cors
Use the middleware
function to set up CORS for your application. This middleware should be
placed early in your middleware stack (late in the pipeline).
+import gleam/http/cors
+import gleam/http
import myproject/web/middleware
pub fn stack() {
service
|> middleware.rescue
|> middleware.log
+ |> cors.middleware(
+ origins: ["http://localhost:8000"],
+ methods: [http.Get, http.Post, http.Delete],
+ headers: ["Authorization", "Content-Type"],
+ )
}
See CHANGELOG.md in the project repository