gleam_cors

Package Version Hex Docs

Unofficial CORS middleware for the gleam_http library.

Installation

gleam add gleam_cors

Usage

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"],
+  )
 }

Changelog

See CHANGELOG.md in the project repository

Search Document