feat: handle cors in-app

This commit is contained in:
silver 2024-02-18 14:29:03 +00:00
parent 100b0d6552
commit 7576b954bb

View file

@ -3,6 +3,10 @@ use skynet_ldap_backend::{
methods::{account_new, account_recover, account_ssh, account_update},
State,
};
use tide::{
http::headers::HeaderValue,
security::{CorsMiddleware, Origin},
};
#[async_std::main]
async fn main() -> tide::Result<()> {
@ -20,6 +24,12 @@ async fn main() -> tide::Result<()> {
let mut app = tide::with_state(state);
let cors = CorsMiddleware::new()
.allow_methods("GET, POST, DELETE, OPTIONS".parse::<HeaderValue>().unwrap())
.allow_origin(Origin::from("*"));
app.with(cors);
// for users to update their own profile
app.at("/ldap/update").post(account_update::submit);