feat: handle cors in-app
This commit is contained in:
parent
100b0d6552
commit
7576b954bb
1 changed files with 10 additions and 0 deletions
10
src/main.rs
10
src/main.rs
|
@ -3,6 +3,10 @@ use skynet_ldap_backend::{
|
||||||
methods::{account_new, account_recover, account_ssh, account_update},
|
methods::{account_new, account_recover, account_ssh, account_update},
|
||||||
State,
|
State,
|
||||||
};
|
};
|
||||||
|
use tide::{
|
||||||
|
http::headers::HeaderValue,
|
||||||
|
security::{CorsMiddleware, Origin},
|
||||||
|
};
|
||||||
|
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() -> tide::Result<()> {
|
async fn main() -> tide::Result<()> {
|
||||||
|
@ -20,6 +24,12 @@ async fn main() -> tide::Result<()> {
|
||||||
|
|
||||||
let mut app = tide::with_state(state);
|
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
|
// for users to update their own profile
|
||||||
app.at("/ldap/update").post(account_update::submit);
|
app.at("/ldap/update").post(account_update::submit);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue