Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ydb/core/mon/async_http_mon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ class THttpMonLegacyActorRequest : public TActorBootstrapped<THttpMonLegacyActor
response << "HTTP/1.1 204 No Content\r\n"
"Access-Control-Allow-Origin: " << origin << "\r\n"
"Access-Control-Allow-Credentials: true\r\n"
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept\r\n"
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
"Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, DELETE\r\n"
"Content-Type: " + type + "\r\n"
"Content-Type: " << type << "\r\n"
"Connection: keep-alive\r\n\r\n";
ReplyWith(request->CreateResponseString(response));
PassAway();
Expand Down
42 changes: 11 additions & 31 deletions ydb/core/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,36 +475,12 @@ class TViewer : public TActorBootstrapped<TViewer>, public IViewer {
if (type.empty()) {
type = "application/json";
}
if (AllowOrigin) {
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
"HTTP/1.1 204 No Content\r\n"
"Access-Control-Allow-Origin: " + AllowOrigin + "\r\n"
"Access-Control-Allow-Credentials: true\r\n"
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
"Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n"
"Allow: OPTIONS, GET, POST\r\n"
"Content-Type: " + type + "\r\n"
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
} else {
TString origin = TString(msg->Request.GetHeader("Origin"));
if (!origin.empty()) {
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
"HTTP/1.1 204 No Content\r\n"
"Access-Control-Allow-Origin: " + origin + "\r\n"
"Access-Control-Allow-Credentials: true\r\n"
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
"Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n"
"Allow: OPTIONS, GET, POST\r\n"
"Content-Type: " + type + "\r\n"
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
} else {
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
"HTTP/1.1 204 No Content\r\n"
"Allow: OPTIONS, GET, POST\r\n"
"Content-Type: " + type + "\r\n"
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
}
}
TStringBuilder response;
response << "HTTP/1.1 204 No Content\r\n";
FillCORS(response, msg);
response << "Content-Type: " + type + "\r\n"
"Connection: Keep-Alive\r\n\r\n";
Send(ev->Sender, new NMon::TEvHttpInfoRes(response, 0, NMon::IEvHttpInfoRes::EContentType::Custom));
return;
}
TString path("/" + msg->Request.GetPage()->Path + msg->Request.GetPathInfo());
Expand Down Expand Up @@ -608,11 +584,15 @@ void TViewer::FillCORS(TStringBuilder& stream, const TRequestState& request) {
} else if (request && request->Request.GetHeaders().HasHeader("Origin")) {
origin = request->Request.GetHeader("Origin");
}
if (origin.empty()) {
origin = "*";
}
if (origin) {
stream << "Access-Control-Allow-Origin: " << origin << "\r\n"
<< "Access-Control-Allow-Credentials: true\r\n"
<< "Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
<< "Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n";
<< "Access-Control-Allow-Methods: OPTIONS, GET, POST, DELETE\r\n"
<< "Allow: OPTIONS, GET, POST, DELETE\r\n";
}
}

Expand Down