Skip to content

fix: filter NIP-05 nostr.json by the ?name query param#4

Merged
sepehr-safari merged 1 commit into
mainfrom
fix/nip05-name-filter
Jul 16, 2026
Merged

fix: filter NIP-05 nostr.json by the ?name query param#4
sepehr-safari merged 1 commit into
mainfrom
fix/nip05-name-filter

Conversation

@sepehr-safari

Copy link
Copy Markdown
Contributor

Problem

/.well-known/nostr.json was a static file (public/.well-known/nostr.json). Static files are served verbatim and can't read a query string, so every handle was returned on every request regardless of the queried name:

GET /.well-known/nostr.json?name=sepehr
→ {"names":{"_":"3e29…","sepehr":"3e29…"}}   # both, always

Fix

Replace the static file with a dynamic App Router route handler that honors the NIP-05 ?name=<local-part> query and returns only the matching mapping — or {"names":{}} when the name is absent/unknown, so handles aren't enumerable.

  • added app/.well-known/nostr.json/route.js
  • deleted public/.well-known/nostr.json
  • modified next.config.mjs — the CORS header moves into the handler so the endpoint owns its whole response (keeping it in both places would emit Access-Control-Allow-Origin twice, which browsers reject).

Note: the NIP-05 query param is name, not user. ?name=sepehr is the correct query; real clients already send it.

Verified (dev + next build)

?name=sepehr → {"names":{"sepehr":"3e29…ca8e"}}
?name=_      → {"names":{"_":"3e29…ca8e"}}
?name=nobody → {"names":{}}
(no param)   → {"names":{}}

Single access-control-allow-origin: *, content-type: application/json, HTTP 200 (no redirect). next build registers the route as ƒ (Dynamic).

Serve /.well-known/nostr.json from a dynamic route handler instead of a
static public/ file. A static file can't read the query string, so every
handle was returned on every request. The handler honors the NIP-05
`?name=<local-part>` query and returns only the requested mapping, or
`{"names":{}}` when the name is absent or unknown.

CORS moves into the handler so the endpoint owns its whole response;
keeping the header in next.config too would emit it twice.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zignostr.com Ready Ready Preview, Comment Jul 16, 2026 5:14pm

@sepehr-safari
sepehr-safari merged commit ed57a98 into main Jul 16, 2026
3 checks passed
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.

1 participant