How to add headers to the response of static resources #4377
-
|
I tried to add a header in leptos_routes, but it only worked for my router requests. .leptos_routes(&leptos_options, routes, {
let leptos_options = leptos_options.clone();
move || {
let opts = expect_context::<leptos_axum::ResponseOptions>();
opts.insert_header(
HeaderName::from_static("cross-origin-opener-policy"),
HeaderValue::from_static("same-origin"),
);
opts.insert_header(
HeaderName::from_static("cross-origin-embedder-policy"),
HeaderValue::from_static("require-corp"),
);
shell(leptos_options.clone())
}
})I saw in the function description that .fallback(leptos_axum::file_and_error_handler_with_context(
move || {
let opts = expect_context::<leptos_axum::ResponseOptions>();
opts.insert_header(
HeaderName::from_static("cross-origin-opener-policy"),
HeaderValue::from_static("same-origin"),
);
opts.insert_header(
HeaderName::from_static("cross-origin-embedder-policy"),
HeaderValue::from_static("require-corp"),
);
println!("{opts:?}");
provide_context(opts);
},
shell,
)) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
It looks like A PR would be welcome to fix this. |
Beta Was this translation helpful? Give feedback.
I fixed his #4394