CORS Origin Input

CORS Origin Input is a copy-paste React component that stops cors allow-list never matches before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/cors-origin-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsCORS allow-list never matches

Was this component page useful?

How do I install CORS Origin Input?

pnpm dlx shadcn@latest add @bollard/cors-origin-input

The files land in your project. They're yours to edit.

How do I use CORS Origin Input in React?

cors-origin-input-usage.tsx
import { CorsOriginInput } from "@/components/ui/cors-origin-input"

<CorsOriginInput
  credentials
  production
  defaultValue={["https://app.acme.com/", "admin.acme.com", "*", "http://localhost:3000", "https://acme.com"]}
/>

What input mistakes does CORS Origin Input catch?

  • * combined with credentials, and the null origin
  • Trailing slashes or paths, which never match an Origin header
  • Missing scheme and explicit default ports
  • http:// or localhost origins in production
  • Near misses when testing an origin against the list

What props does CORS Origin Input accept?

CorsOriginInput props
PropTypeDefault
value

Allowed origins (controlled).

string[]—
defaultValue

Allowed origins when uncontrolled.

string[][]
onValueChange

Called with the origin list whenever it changes.

(origins: string[]) => void—
credentials

Credentials are allowed for this API. Makes * and *. errors.

booleanfalse
production

This list is for production. Flags http and localhost.

booleanfalse
label

Visible label for the allow-list.

string"Allowed origins"
placeholder

Placeholder for the add-origin field.

string"https://app.example.com"
messages

Text per issue.

Partial<Record<OriginIssueKind, string>>—
useLabel

Fix button labels. `{fix}` is filled in.

string"Use {fix}"
removeLabel

Accessible label prefix for remove buttons.

string"Remove"
fixAllLabel

`{count}` is filled in.

string"Fix {count}"
testLabel

Label for the origin tester.

string"Test an origin"
testPlaceholder

Placeholder for the origin tester.

string"https://www.example.com"
testMessages

Tester results. `{origin}` and `{entry}` are filled in.

Partial<Record<OriginTestCode, string>>—
credentialsOnLabel

Context shown beside the label.

string"credentials: true"
credentialsOffLabel

Text shown when credentials are not allowed.

string"no credentials"
productionLabel

Text marking the production environment.

string"prod"
errorLabel

Read to screen readers after an entry that has an error or a warning.

string"error"
warningLabel

Word read for warning-level issues.

string"warning"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is CORS Origin Input accessible?

  • Labelled add field; origins are a labelled list with remove buttons named per origin
  • aria-invalid and aria-describedby to an aria-live="polite" issues region
  • Severity is stated in text (", error" / ", warning"), not just colour
  • Enter adds an origin; focus moves sensibly after removals and fixes

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce CORS in the server or gateway with exact origin matching, and authenticate API requests independently of CORS.

  • Checks the list text; your server's CORS middleware may normalise or match differently
  • CORS controls browsers only; it is not access control for the API

What expensive mistakes does CORS Origin Input stop?

CORS allow-list never matches

Also known as

cors · allowed origins · access-control-allow-origin · api config · express cors · preflight · credentials

Field type

What dependencies does CORS Origin Input require?

CORS Origin Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameCORS Origin Input
Registry identifier@bollard/cors-origin-input
Install commandnpx shadcn@latest add @bollard/cors-origin-input
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about CORS Origin Input

What form validation mistake does CORS Origin Input catch?

CORS Origin Input prevents cORS allow-list never matches. Checks a CORS allow-list for origins that never match or open the API to every site, and tests an origin against it. Catches: * combined with credentials, and the null origin, Trailing slashes or paths, which never match an Origin header, Missing scheme and explicit default ports, http:// or localhost origins in production, Near misses when testing an origin against the list. Limitation: validate cors-origin-input schemas on backend.

How do I install cors-origin-input with shadcn?

Run `npx shadcn@latest add @bollard/cors-origin-input`. Sources added: registry/default/cors-origin-input/cors-origin-input.tsx. Package requirements: lucide-react.

What props customize CORS Origin Input?

CORS Origin Input accepts `value`, `defaultValue`, `onValueChange`, `credentials`, `production`. Configures cors, allowed origins, access-control-allow-origin behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of cors-origin-input?

Checks the list text; your server's CORS middleware may normalise or match differently. CORS controls browsers only; it is not access control for the API Server requirement: Enforce CORS in the server or gateway with exact origin matching, and authenticate API requests independently of CORS.

How does CORS Origin Input meet accessibility guidelines?

Labelled add field; origins are a labelled list with remove buttons named per origin. aria-invalid and aria-describedby to an aria-live="polite" issues region. Severity is stated in text (", error" / ", warning"), not just colour. Enter adds an origin; focus moves sensibly after removals and fixes. Minimizes errors: cors error trailing slash, access-control-allow-origin star credentials.

Which components pair with CORS Origin Input?