Skip to content

fix(registry): add Accept: application/json header to fetchRegistry#10168

Open
cyphercodes wants to merge 1 commit intoshadcn-ui:mainfrom
cyphercodes:main
Open

fix(registry): add Accept: application/json header to fetchRegistry#10168
cyphercodes wants to merge 1 commit intoshadcn-ui:mainfrom
cyphercodes:main

Conversation

@cyphercodes
Copy link
Copy Markdown

When fetching from registry URLs, the CLI now sends an Accept: application/json header. This allows custom registries to use content negotiation to serve JSON to the CLI while serving HTML documentation to browsers at the same URL.

Problem

When using shadcn add with a custom registry URL, the CLI doesn't send an Accept header. This prevents registries from using standard HTTP content negotiation to serve different content types based on the client.

Solution

Add Accept: application/json header to the fetch request in fetchRegistry.

Testing

  • Verified the header is included in requests
  • Allows registries to differentiate between CLI and browser requests

Fixes #10164

When fetching from registry URLs, the CLI now sends an Accept: application/json
header. This allows custom registries to use content negotiation to serve JSON
to the CLI while serving HTML documentation to browsers at the same URL.

Fixes shadcn-ui#10164
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 25, 2026

@cyphercodes is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

@EthanThatOneKid
Copy link
Copy Markdown

Hi @cyphercodes, thanks for opening this!

I was working on the same fix and just submitted PR #10179. Since yours was first, I wanted to note that I've included a suite of unit tests in my PR. If you'd like to pull those tests into your PR to make it more robust for the maintainers, feel free! I'll leave mine open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI should send Accept: application/json headers when fetching from a registry URL

2 participants