Skip to main content
Deno 2 is finally here 🎉️
Learn more

cors

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

CORS protocol for standard Request and Response.

Packages

The package supports multiple platforms.

  • deno.land/x - https://deno.land/x/cors_protocol/mod.ts
  • npm - @httpland/cors

Treat CORS automatically

withCors accept HTTP request handler and add CORS headers to response header.

import { withCors } from "https://deno.land/x/cors_protocol@$VERSION/mod.ts";
import { Handler, serve } from "https://deno.land/std@$VERSION/http/mod.ts";

function handler(req: Request): Response {
  return new Response("Hello");
}

await serve(withCors(handler));

then, the endpoint support simple request and preflight request.

License

Copyright © 2022-present httpland.

Released under the MIT license