Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

CORS Allowed Origins Settings Block for React

A CORS settings panel that checks its own origin list for four unsafe patterns, each with a Fix button that rewrites the list, plus origin rows with an environment tag, a validating add form and a policy band for credentials and preflight cache.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Show people what is unsafe about their list of allowed origins, with this CORS settings panel for React with Base UI. A hairline frame with a plus mark on each corner leads with four checks that run over the list and the policy: no wildcard origin, https for every Production origin, no localhost in Production, and no wildcard combined with credentials. Each says what it found in a sentence and has a Button that fixes it (Remove , Use https, Tag as Local, Turn credentials off), which rewrites the list and moves the count in the heading. Below, the origins are rows with the address in monospace, an environment tag in a Native Select (Production, Staging, Local) and a Remove button. An add form takes an address and a tag and refuses a missing scheme, a path, a wildcard anywhere but in front ("https://.example.com") and a duplicate, saying why beside the field. A policy band has an Allow credentials Switch and a Number Input for how many seconds a browser may reuse a preflight, each with the sentence it amounts to. The action foot counts unsaved changes beside a Shine Button that saves them and an outline button that discards them. It's built from Switch, Number Input, Native Select, Field, Input, Button, Shine Button and Guides, with a CSS entrance only. For a headless CMS, an API gateway or any backend that answers browsers.

FAQ

How do I fill it with my own origins?

Edit SAVED at the top: each origin has an id, an environment tag and an address, and the policy has a credentials flag and a max age in seconds. RULES names the four checks and what each says while it passes, and findingOf holds what each reports when it fails. The counts, the Fix labels and the sentences under the policy controls are all worked out from the list, so nothing is typed twice.

What do the four checks look for, and what does each Fix do?

A wildcard origin is an origin that is *; its fix removes it. An insecure origin is a Production origin on plain http that isn't localhost; its fix rewrites each to https and drops duplicates. A localhost origin in Production is a localhost or 127.0.0.1 address tagged Production; its fix tags it Local. A wildcard with credentials is * listed while credentials are on, which browsers refuse; its fix turns credentials off. A passing check keeps its place and says so, and its button stays on the row as a quiet "Passes", so focus and height never move when you fix something.

What does the add form accept?

An origin is a scheme and a host, with an optional port: https://app.example.com or http://localhost:3000. It refuses a missing scheme, anything after the host (a path, a query or a fragment), a wildcard that isn't a leading *. and an address already on the list, and it says which in the field's message, keeping the text so you can fix it. A lone * is allowed on purpose, so you can see the first check complain. Enter adds the origin without saving the form.

What stays local, and how do I make it real?

Everything. Nothing is enforced, saved or requested: the origins, the fixes and the policy live in this page's state, and Save only says what it kept. To make it real, send the saved list to your API and have it answer preflights from it, then keep running the same checks on the server so an unsafe list can't be saved by another route. Saving with checks still failing is allowed here, and the status line says how many.

What do the credentials switch and the preflight number do?

Credentials say whether browsers may send cookies and sign-in headers across origins; the sentence under the switch says what that means for this list, including when a wildcard makes browsers refuse them. The number is how long a browser may reuse a preflight answer, 0 to 86,400 seconds, and the sentence turns it into minutes or hours and notes that Chrome keeps a preflight at most two hours. A value outside the range is refused when you save, with focus on the field. The number field commits when you leave it or press Enter on some libraries, so type, then move on.

  • Pro

    IP Allowlist Settings

    Sign-in and security

    An IP allowlist settings panel with an enforcement switch and a lockout guard that says whether your own address is covered, a rules table, and an add form that parses IPv4 and IPv6 ranges and names the rule that already covers a new one.

  • Pro

    Environment Variables Settings

    Domains and delivery

    An environment variables settings panel that shows where each variable is set across Production, Preview and Development, counts what is missing, fills a missing value with Copy from, and previews a pasted .env file before it imports.

  • Pro

    API Key Builder Settings

    API and webhooks

    An API key settings panel with a table of keys, a builder that sets None, Read or Write for each resource, and a try-a-request check that answers Allowed or Denied with the reason before anything is saved.

  • Pro

    A webhook endpoint settings sheet open over the endpoint list: an https URL, an event tree with mixed-state group checkboxes, a signing secret with Roll secret, and recent deliveries where a failed one can be resent with its signature worked out in the browser.

  • Pro

    Access Token Hygiene Settings

    Sign-in and security

    An access token settings panel that flags risky tokens (no end date, unused for 90 days, the admin scope, ending soon), gives a token an end date from a menu, and revokes the ticked ones after an alert dialog lists them.

  • Pro

    A matrix of API limits with the plans across and a number field in every cell, a daily capacity worked out under each plan and a guard that stops a higher plan from allowing less than the plan before it.