upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/05.md
diff options
context:
space:
mode:
authorDavid A. Harding <dave@dtrt.org>2022-05-07 08:31:02 -1000
committerfiatjaf <fiatjaf@gmail.com>2022-05-07 17:18:23 -0300
commit57b86d2482509bad04067e646b130c41f9433923 (patch)
tree565b103958172377ae971d098441e59644017a2b /05.md
parentd7a4aad4a0039285f2bc4723c2898593dca0d6c4 (diff)
NIP05: warn about CORS policies that may inhibit JS apps
JS Nostr apps such as Branle may not be able to load `nostr.json` files due to CORS policies. Update NIP05 to warn about this and provide hints for troubleshooting and fixing the issue.
Diffstat (limited to '05.md')
-rw-r--r--05.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/05.md b/05.md
index a006ac1..3267960 100644
--- a/05.md
+++ b/05.md
@@ -50,3 +50,16 @@ Clients may treat the identifier `_@domain` as the "root" identifier, and choose
50### Reasoning for the `/.well-known/nostr.json?name=<local-part>` format 50### Reasoning for the `/.well-known/nostr.json?name=<local-part>` format
51 51
52By adding the `<local-part>` as a query string instead of as part of the path the protocol can support both dynamic servers that can generate JSON on-demand and static servers with a JSON file in it that may contain multiple names. 52By adding the `<local-part>` as a query string instead of as part of the path the protocol can support both dynamic servers that can generate JSON on-demand and static servers with a JSON file in it that may contain multiple names.
53
54### Allowing access from Javascript apps
55
56Javascript Nostr apps may be restricted by browser [CORS][] policies that prevent them from accesing `nostr.json` on the user's domain. When CORS prevents JS from loading a resource, the JS program sees it as a network failure identical to the resource not existing, so it is not possible for a pure-JS app to tell the user for certain that the failure was caused by a CORS issue. JS Nostr apps that see network failures requesting `nostr.json` files may want to recommend to users that they check the CORS policy of their servers, e.g.:
57
58```bash
59$ curl -sI https://example.com/.well-known/nostr.json?name=bob | grep ^Access-Control
60Access-Control-Allow-Origin: *
61```
62
63Users should ensure that their `nostr.json` is served with the HTTP header `Access-Control-Allow-Origin: *` to ensure it can be validated by pure JS apps running in modern browsers.
64
65[CORS]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS