add csp draft

This commit is contained in:
2025-01-17 18:48:28 +01:00
parent 82862f0e3e
commit c13e53404c
2 changed files with 23 additions and 0 deletions

View File

@@ -1,7 +1,11 @@
use std::{collections::HashMap, sync::Arc};
use axum::{
body::Body,
extract::{DefaultBodyLimit, Request},
http::HeaderValue,
middleware::{self, Next},
response::Response,
routing::{delete, get, post},
Router, ServiceExt,
};
@@ -19,6 +23,7 @@ use tower_http::{
extern crate lazy_static;
mod config;
mod csp;
mod health;
mod lock;
mod note;
@@ -55,6 +60,8 @@ async fn main() {
let app = Router::new()
.nest("/api", api_routes)
.fallback_service(serve_dir)
// Disabled for now, as svelte inlines scripts
// .layer(middleware::from_fn(csp::add_csp_header))
.layer(DefaultBodyLimit::max(*config::LIMIT))
.layer(
CompressionLayer::new()