Permalink
Browse files

CORS needs Access-Control-Allow-Headers header (#192)

  • Loading branch information...
1 parent 559307c commit 6385c234ef43fa0a26bf28d32906f88e0faf464a @melpon committed Nov 29, 2016
Showing with 8 additions and 0 deletions.
  1. +8 −0 kennel2/src/kennel.cpp
@@ -138,6 +138,9 @@ class kennel : public cppcms::application {
response().status(200);
response().allow("OPTIONS, GET, HEAD");
response().set_header("Access-Control-Allow-Origin", "*");
+ auto headers = request().getenv("HTTP_ACCESS_CONTROL_REQUEST_HEADERS");
+ if (!headers.empty())
+ response().set_header("Access-Control-Allow-Headers", headers);
return false;
} else {
response().status(405);
@@ -155,6 +158,11 @@ class kennel : public cppcms::application {
response().status(200);
response().allow("OPTIONS, POST");
response().set_header("Access-Control-Allow-Origin", "*");
+ //for (auto it = request().getenv().begin(); it != request().getenv().end(); ++it)
+ // std::cout << it->first << ": " << it->second << std::endl;
+ auto headers = request().getenv("HTTP_ACCESS_CONTROL_REQUEST_HEADERS");
+ if (!headers.empty())
+ response().set_header("Access-Control-Allow-Headers", headers);
return false;
} else {
response().status(405);

0 comments on commit 6385c23

Please sign in to comment.