fix: filter NIP-05 nostr.json by the ?name query param#4
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/.well-known/nostr.jsonwas 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: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.app/.well-known/nostr.json/route.jspublic/.well-known/nostr.jsonnext.config.mjs— the CORS header moves into the handler so the endpoint owns its whole response (keeping it in both places would emitAccess-Control-Allow-Origintwice, which browsers reject).Verified (dev +
next build)Single
access-control-allow-origin: *,content-type: application/json, HTTP 200 (no redirect).next buildregisters the route asƒ (Dynamic).