leptos-rs/leptos · critical
Unsupported server function HTTP method: {method:?}
Error message
Unsupported server function HTTP method: {method:?} What it means
leptos's Axum integration builds a route for each server function based on the HTTP method stored in the server function's metadata. Only GET, POST, PUT, DELETE, and PATCH are mapped to Axum's method routers; any other method causes an immediate panic while constructing the router.
Source
Thrown at integrations/axum/src/lib.rs:1842
// register server functions
for (path, method) in server_fn::axum::server_fn_paths() {
let cx_with_state = cx_with_state.clone();
let handler = move |req: Request<Body>| async move {
handle_server_fns_with_context(cx_with_state, req).await
};
if !excluded.contains(path) {
router = router.route(
path,
match method {
Method::GET => get(handler),
Method::POST => post(handler),
Method::PUT => put(handler),
Method::DELETE => delete(handler),
Method::PATCH => patch(handler),
_ => {
panic!(
"Unsupported server function HTTP method: \
{method:?}"
);
}
},
);
}
}
// register router paths
for listing in paths.iter().filter(|p| !p.exclude) {
let path = listing.path();
for method in listing.methods() {
let cx_with_state = cx_with_state.clone();
let cx_with_state_and_method = move || {
provide_context(method);
cx_with_state();View on GitHub (pinned to 32d20f6c9d)
Solutions
- Change the server function to use GET, POST, PUT, DELETE, or PATCH (the default is POST).
- If a custom method is truly required, add a match arm mapping it to the corresponding Axum method-router helper before the catch-all panic.
- Verify the config passed to #[server(...)] (e.g. `method = ...`) only uses supported verbs.
Example fix
// before
#[server(FetchThing, "/api")]
#[cfg_attr(feature = "ssr", server(method = HEAD))]
async fn fetch_thing() -> Result<(), ServerFnError> { ... }
// after
#[server(FetchThing, "/api")]
#[cfg_attr(feature = "ssr", server(method = GET))]
async fn fetch_thing() -> Result<(), ServerFnError> { ... } Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED: &[&str] = &["GET", "POST", "PUT", "DELETE", "PATCH"];
fn server_fn_method_supported(method: &str) -> bool {
SUPPORTED.contains(&method.to_uppercase().as_str())
} Type guard
fn is_supported_method(m: &http::Method) -> bool {
matches!(m, &http::Method::GET | &http::Method::POST | &http::Method::PUT | &http::Method::DELETE | &http::Method::PATCH)
} Prevention
- Stick to the default POST method or the five supported verbs in #[server] config.
- Review generated server-function registrations in CI for non-standard methods.
- Add a build-time test that leptos_routes() constructs without panicking for all registered functions.
When it happens
Trigger: Calling LeptosRoutes::leptos_routes/leptos_routes_with_context on an Axum router when a registered server function declares an HTTP method outside the supported set (e.g. via custom #[server] macro configuration setting method to HEAD or OPTIONS).
Common situations: Customizing server function methods with non-standard verbs; hand-written or generated server function registrations with typos in the method; using a macro or codegen that emits methods Axum routing helpers here don't cover.
Related errors
- Failed to find the route {path} requested by the user. This
- {}
- Reading from a LocalResource outside Suspense in `ssr` mode
- at {location}, the `sandboxed-arenas` feature is active, but
- failed to spawn future on ThreadPool
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/a2b9ff1de8b89d09.
Report an issue: GitHub.