fix(router): NIP-11 being served only on root instead of relay path#399
Open
sagar-h007 wants to merge 1 commit intocameri:mainfrom
Open
fix(router): NIP-11 being served only on root instead of relay path#399sagar-h007 wants to merge 1 commit intocameri:mainfrom
sagar-h007 wants to merge 1 commit intocameri:mainfrom
Conversation
cameri
reviewed
Apr 8, 2026
| const settings = createSettings() | ||
|
|
||
| if (request.header('accept') === 'application/nostr+json') { | ||
| if (request.header('accept')?.includes('application/nostr+json')) { |
Owner
There was a problem hiding this comment.
Can you elaborate a bit why we can't use a strict equality check here?
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.
Description
This PR fixes an issue where the NIP-11 relay information document was only being served at the root (
/) of the domain, even when the relay itself was configured on a different path (for example/v1).Specifically, this PR introduces the following changes:
Accept: application/nostr+json.includesinstead of strict equality).Related Issue
#381
Motivation and Context
According to the NIP-11 spec, the relay metadata should be available on the same URI that handles the WebSocket connection. In practice, this means a relay at
wss://domain.com/v1should expose its NIP-11 document athttps://domain.com/v1, not just athttps://domain.com/.Previously, WebSocket upgrades in Nostream were effectively path-agnostic, while Express routes were explicitly bound to
/. As a result, requests likeGET /v1withAccept: application/nostr+jsonreturned a404instead of the expected NIP-11 response. This change keeps the fix minimal while aligning behavior more closely with the NIP-11 spec and how relays are typically exposed behind proxies or path prefixes.How Has This Been Tested?
Tested locally by verifying that NIP-11 is now correctly served on the relay path (e.g.,
/v1). Verified that the existing behavior on the root (/) remains unchanged and that the updated handler successfully processes requests from real-world clients sending compound Accept headers.Test run:
curl -H "Accept: application/nostr+json" http://localhost:8008/v1Types of changes
Checklist: