Axeom Logo
Axeom.
Plugins

CORS

Cross-Origin Resource Sharing for secure communication.

The @axeom/cors plugin provides a simple way to manage Cross-Origin requests. It handles pre-flight OPTIONS requests and sets the appropriate headers based on your configuration.


Installation

npm install @axeom/cors

Usage

import Axeom from '@axeom/framework';
import { cors } from '@axeom/cors';

const app = new Axeom().use(cors({
  origin: "https://axeom.dev",
  methods: ["GET", "POST", "DELETE"],
  credentials: true
}));

Configuration Options

OptionTypeDefaultDescription
originstring | string[] | boolean"*"Allowed origins. true mirrors the request origin.
methodsstring[]["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]Allowed HTTP methods.
allowedHeadersstring[][]Explicitly allowed request headers.
exposedHeadersstring[][]Headers exposed to the client.
credentialsbooleanfalseWhether to allow cookies/auth headers.
maxAgenumberundefinedHow long the pre-flight results can be cached.

On this page