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:
parent
5b005b48aa
commit
958ec2a758
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue