Allow CORS in production for yew app

This commit is contained in:
Shaun Bennett 2020-10-19 23:24:51 -04:00
parent a7989700fb
commit a5776125a0
1 changed files with 12 additions and 0 deletions

View File

@ -585,6 +585,18 @@ async fn main() -> Result<(), tide::Error> {
{
info!("Activating RELEASE mode configuration");
app.with(driftwood::ApacheCombinedLogger);
use tide::security::{CorsMiddleware, Origin};
let cors = CorsMiddleware::new()
.allow_methods(
"GET, POST, PUT, OPTIONS"
.parse::<tide::http::headers::HeaderValue>()
.unwrap(),
)
.allow_origin(Origin::from("https://shaunbennett.github.io"))
.allow_credentials(false);
app.with(cors);
}
#[cfg(debug_assertions)]