From 5edd9c85f2e1a9db1717b74b3873b888bed89562 Mon Sep 17 00:00:00 2001 From: Libor Chocholaty <65256887+liborch@users.noreply.github.com> Date: Fri, 15 May 2026 12:44:27 +0200 Subject: [PATCH] Support explicit OPTIONS routes --- include/crow/routing.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/crow/routing.h b/include/crow/routing.h index 57d23e010..5149fc06b 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -1644,6 +1644,17 @@ namespace crow // NOTE: Already documented in "crow/app.h" } else if (req.method == HTTPMethod::Options) { + // Prefer explicit OPTIONS routes while preserving the automatic "/*" handler. + if (req.url != "/*") + { + *found = per_methods_[static_cast(HTTPMethod::Options)].trie.find(req.url); + if (found->rule_index) + { + found->method = HTTPMethod::Options; + return found; + } + } + std::string allow = "OPTIONS, HEAD"; if (req.url == "/*")