nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 0a3b15f41f7c65122d998e1cb17583a98c554d94
parent 2b4b17dbdaa7c01f3b54e0e54a7edcb13e5d497c
Author: Greg Heartsfield <scsibug@imap.cc>
Date:   Thu, 11 Aug 2022 19:33:17 -0700

fix(NIP-11): Add CORS header and content type for main page

Diffstat:
Msrc/main.rs | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,3 +1,4 @@ + //! Server process use futures::SinkExt; use futures::StreamExt; @@ -132,16 +133,19 @@ async fn handle_web_request( let rinfo = RelayInfo::from(config.info.clone()); let b = Body::from(serde_json::to_string_pretty(&rinfo).unwrap()); return Ok(Response::builder() - .status(200) - .header("Content-Type", "application/nostr+json") - .body(b) - .unwrap()); + .status(200) + .header("Content-Type", "application/nostr+json") + .header("Access-Control-Allow-Origin", "*") + .body(b) + .unwrap()); } } } - Ok(Response::new(Body::from( - "Please use a Nostr client to connect.", - ))) + Ok(Response::builder() + .status(200) + .header("Content-Type", "text/plain") + .body(Body::from("Please use a Nostr client to connect.")).unwrap() + ) } (_, _) => { //handle any other url