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 == "/*")