@@ -536,12 +536,36 @@ class TViewer : public TActorBootstrapped<TViewer>, public IViewer {
536
536
if (type.empty ()) {
537
537
type = " application/json" ;
538
538
}
539
- TStringBuilder response;
540
- response << " HTTP/1.1 204 No Content\r\n " ;
541
- FillCORS (response, msg);
542
- response << " Content-Type: " + type + " \r\n "
543
- " Connection: Keep-Alive\r\n\r\n " ;
544
- Send (ev->Sender , new NMon::TEvHttpInfoRes (response, 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
539
+ if (AllowOrigin) {
540
+ ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
541
+ " HTTP/1.1 204 No Content\r\n "
542
+ " Access-Control-Allow-Origin: " + AllowOrigin + " \r\n "
543
+ " Access-Control-Allow-Credentials: true\r\n "
544
+ " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
545
+ " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n "
546
+ " Allow: OPTIONS, GET, POST\r\n "
547
+ " Content-Type: " + type + " \r\n "
548
+ " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
549
+ } else {
550
+ TString origin = TString (msg->Request .GetHeader (" Origin" ));
551
+ if (!origin.empty ()) {
552
+ ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
553
+ " HTTP/1.1 204 No Content\r\n "
554
+ " Access-Control-Allow-Origin: " + origin + " \r\n "
555
+ " Access-Control-Allow-Credentials: true\r\n "
556
+ " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
557
+ " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n "
558
+ " Allow: OPTIONS, GET, POST\r\n "
559
+ " Content-Type: " + type + " \r\n "
560
+ " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
561
+ } else {
562
+ ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
563
+ " HTTP/1.1 204 No Content\r\n "
564
+ " Allow: OPTIONS, GET, POST\r\n "
565
+ " Content-Type: " + type + " \r\n "
566
+ " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
567
+ }
568
+ }
545
569
return ;
546
570
}
547
571
TString path (" /" + msg->Request .GetPage ()->Path + msg->Request .GetPathInfo ());
@@ -652,8 +676,7 @@ void TViewer::FillCORS(TStringBuilder& stream, const TRequestState& request) {
652
676
stream << " Access-Control-Allow-Origin: " << origin << " \r\n "
653
677
<< " Access-Control-Allow-Credentials: true\r\n "
654
678
<< " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
655
- << " Access-Control-Allow-Methods: OPTIONS, GET, POST, DELETE\r\n "
656
- << " Allow: OPTIONS, GET, POST, DELETE\r\n " ;
679
+ << " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n " ;
657
680
}
658
681
}
659
682
0 commit comments