Add CORS header (#1382)

I was having an issue with `zola serve` where the browser was not
fetching fonts on account of it not sending a CORS header with the
fonts
This commit is contained in:
Jade 2021-03-17 01:11:02 -07:00 committed by GitHub
parent 5b005b48aa
commit 958ec2a758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -128,7 +128,11 @@ async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Respons
Ok(Response::builder() Ok(Response::builder()
.status(StatusCode::OK) .status(StatusCode::OK)
.header("Content-Type", mimetype_from_path(&root).first_or_octet_stream().essence_str()) .header(
header::CONTENT_TYPE,
mimetype_from_path(&root).first_or_octet_stream().essence_str(),
)
.header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*")
.body(Body::from(contents)) .body(Body::from(contents))
.unwrap()) .unwrap())
} }