You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using the following code snippet to handle a POST request method in my application, and I want to make sure that it doesn't handle any other request methods. However, when I perform an OPTIONS request, it returns a 204 No Content response status, indicating that it's processing the OPTIONS request. I also attempted to replace POST with OPTIONS, but the code doesn't seem to enter the function. CROW_ROUTE(app, "URL").methods("POST"_method).name("hello")([](const crow::request& req){});
Using CORS
auto &cors = app.get_middleware<crow::CORSHandler>();
// Configure CORS
// clang-format off
cors
.global()
.methods("POST"_method, "GET"_method)
.prefix("/")
.origin("URL")
.allow_credentials();
// clang-format on
``
// OPTIONS request handling for "/write"
CROW_ROUTE(app, "/write")
.methods(crow::HTTPMethod::OPTIONS)
([](const crow::request& req) {
return crow::response(crow::status::OK);
});
// GET request handling for "/write"
CROW_ROUTE(app, "/write")
.methods(crow::HTTPMethod::GET)
([](const crow::request& req) {
CROW_LOG_INFO << "Sending response";
return crow::response(crow::status::OK, "This is a response");
});`
```
Also I tried using core middleware, but it didn't work as expected. It is not getting inside the OPTIONS method.
The text was updated successfully, but these errors were encountered:
I tried using the following code snippet to handle a POST request method in my application, and I want to make sure that it doesn't handle any other request methods. However, when I perform an OPTIONS request, it returns a 204 No Content response status, indicating that it's processing the OPTIONS request. I also attempted to replace POST with OPTIONS, but the code doesn't seem to enter the function.
CROW_ROUTE(app, "URL").methods("POST"_method).name("hello")([](const crow::request& req){});
Using CORS
The text was updated successfully, but these errors were encountered: