fn make_cors() -> Cors {
let allowed_origins = AllowedOrigins::some_exact(&[
"http://127.0.0.1:5500/Html_Rust_server/index.html",
// allow request from these
// allow from local machine
]);
CorsOptions {
allowed_origins,
allowed_methods: vec![Method::Get, Method::Post, Method::Put, Method::Delete]
.into_iter()
.map(From::from)
.collect(),
allowed_headers: AllowedHeaders::some(&[
"Authorization",
"Accept",
"Access-Control-Allow-Origin",
]),
allow_credentials: true, // without user name and password
..Default::default()
}
.to_cors() // convert to cross origin
.expect("Error while building the Cros")
}
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.