feat: resolve divine.video/@username to subdomain via NIP-05#218
feat: resolve divine.video/@username to subdomain via NIP-05#218
Conversation
🚀 Preview Deployment
|
|
CF Pages preview URLs: |
Deploying divine-web with
|
| Latest commit: |
2afac08
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b098b078.divine-web.pages.dev |
| Branch Preview URL: | https://feat-at-username-redirect.divine-web.pages.dev |
NotThatKindOfDrLiz
left a comment
There was a problem hiding this comment.
This looks close, but I think the host behavior needs to be clarified before we merge it.
Right now the implementation does the NIP-05 lookup with a relative fetch to /.well-known/nostr.json?name=..., but the redirect target is always hardcoded to https://{username}.divine.video. Those two choices only clearly line up when the app is being served from the apex host.
For example, the spec calls out alice.divine.video/@bob and says it should redirect to bob.divine.video, but with the current code the lookup would happen against alice.divine.video/.well-known/nostr.json?name=bob, not obviously against the canonical apex host. Unless subdomains also serve the same NIP-05 file, that case would fail and show User Not Found instead.
I don't know which behavior is actually intended here, so I think we should clarify that first and then make the code and spec match it.
Can you please either:
- confirm that all relevant hosts/subdomains serve the same
/.well-known/nostr.json, in which case the current relative fetch approach is correct, or - narrow the supported behavior to apex-host
divine.video/@usernamerequests and make that explicit in the implementation/spec, or - change the lookup/redirect logic so both are derived from the same canonical host rule.
Also, the spec doc should be updated to match the implementation: it currently says the route is added in AppRouter.tsx, but the actual diff hooks into NIP19Page.tsx.
Once the intended host behavior is clear and the doc is aligned, this should be in good shape.
|
@NotThatKindOfDrLiz The answer is option 1: all relevant hosts serve There's a subtlety though -- subdomain NIP-05 returns the subdomain owner's data ( On the spec doc question: it already says No code changes needed. Happy to add a comment in the component clarifying why the relative fetch works across hosts if that would help. |
|
Matt, thanks for the follow-up. I took another pass through the current PR head and the related code/comments, and I still think there are two things we should clear up before merging. On the host-behavior point: I’m still not seeing the guard you described for subdomain I also re-checked the spec doc in the PR head, and I’m still seeing the AppRouter references there. The route section says “New route Given that, I think the safest next step is still to keep this blocked until we do one of these:
Once the host behavior is nailed down and the spec matches the implementation, I think this will be in good shape. |
|
Thanks Liz. Added a subdomain guard (d017eb9): if on a subdomain, skip the NIP-05 fetch and redirect to |
NIP19Page detects @-prefixed identifiers and delegates to AtUsernamePage, which fetches /.well-known/nostr.json and redirects to username.divine.video. Relative NIP-05 fetch makes this testable on any host (CI, staging, prod).
On subdomains, NIP-05 serves the subdomain owner instead of the ?name= query. Detect subdomain via getSubdomainUser() and redirect to the apex divine.video/@username first, where the lookup resolves correctly. Spec updated to match implementation (NIP19Page delegation, subdomain guard, CF Pages degradation, corrected file list and test inventory).
e641c1c to
2afac08
Compare
Summary
divine.video/@usernamenow resolves via NIP-05 lookup and redirects tousername.divine.video/:nip19catch-all (NIP19Page detects@prefix, delegates to new AtUsernamePage)/.well-known/nostr.jsonfetch, so the component degrades gracefully on hosts without NIP-05 (CF Pages returns 404, user sees "User Not Found")Test plan
divine.video/@kingbach(or staging equivalent on Fastly), confirm redirect tokingbach.divine.videodivine.video/@nonexistent, confirm "User Not Found" card