oRPC CORS Plugin

CORS Plugin for oRPC.

SKILL.md

GitHub

CORS Plugin

CORSPlugin allows you to configure CORS for your API.

Basic

import { CORSPlugin } from '@orpc/server/plugins'

const handler = new RPCHandler(router, {
  plugins: [
    new CORSPlugin({
      origin: (origin, options) => origin,
      allowMethods: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH'],
      // ...
    }),
  ],
})

The handler can be any supported oRPC handler — RPCHandler, OpenAPIHandler, or a custom handler.