mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-09 21:29:06 -05:00
fix(NIP-11): Add CORS header and content type for main page
This commit is contained in:
parent
2b4b17dbda
commit
0a3b15f41f
18
src/main.rs
18
src/main.rs
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
//! Server process
|
//! Server process
|
||||||
use futures::SinkExt;
|
use futures::SinkExt;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
@ -132,16 +133,19 @@ async fn handle_web_request(
|
||||||
let rinfo = RelayInfo::from(config.info.clone());
|
let rinfo = RelayInfo::from(config.info.clone());
|
||||||
let b = Body::from(serde_json::to_string_pretty(&rinfo).unwrap());
|
let b = Body::from(serde_json::to_string_pretty(&rinfo).unwrap());
|
||||||
return Ok(Response::builder()
|
return Ok(Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
.header("Content-Type", "application/nostr+json")
|
.header("Content-Type", "application/nostr+json")
|
||||||
.body(b)
|
.header("Access-Control-Allow-Origin", "*")
|
||||||
.unwrap());
|
.body(b)
|
||||||
|
.unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Response::new(Body::from(
|
Ok(Response::builder()
|
||||||
"Please use a Nostr client to connect.",
|
.status(200)
|
||||||
)))
|
.header("Content-Type", "text/plain")
|
||||||
|
.body(Body::from("Please use a Nostr client to connect.")).unwrap()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
(_, _) => {
|
(_, _) => {
|
||||||
//handle any other url
|
//handle any other url
|
||||||
|
|
Loading…
Reference in New Issue
Block a user