@@ -475,36 +475,12 @@ class TViewer : public TActorBootstrapped<TViewer>, public IViewer {
475
475
if (type.empty ()) {
476
476
type = " application/json" ;
477
477
}
478
- if (AllowOrigin) {
479
- ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
480
- " HTTP/1.1 204 No Content\r\n "
481
- " Access-Control-Allow-Origin: " + AllowOrigin + " \r\n "
482
- " Access-Control-Allow-Credentials: true\r\n "
483
- " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
484
- " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n "
485
- " Allow: OPTIONS, GET, POST\r\n "
486
- " Content-Type: " + type + " \r\n "
487
- " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
488
- } else {
489
- TString origin = TString (msg->Request .GetHeader (" Origin" ));
490
- if (!origin.empty ()) {
491
- ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
492
- " HTTP/1.1 204 No Content\r\n "
493
- " Access-Control-Allow-Origin: " + origin + " \r\n "
494
- " Access-Control-Allow-Credentials: true\r\n "
495
- " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
496
- " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n "
497
- " Allow: OPTIONS, GET, POST\r\n "
498
- " Content-Type: " + type + " \r\n "
499
- " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
500
- } else {
501
- ctx.Send (ev->Sender , new NMon::TEvHttpInfoRes (
502
- " HTTP/1.1 204 No Content\r\n "
503
- " Allow: OPTIONS, GET, POST\r\n "
504
- " Content-Type: " + type + " \r\n "
505
- " Connection: Keep-Alive\r\n\r\n " , 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
506
- }
507
- }
478
+ TStringBuilder response;
479
+ response << " HTTP/1.1 204 No Content\r\n " ;
480
+ FillCORS (response, msg);
481
+ response << " Content-Type: " + type + " \r\n "
482
+ " Connection: Keep-Alive\r\n\r\n " ;
483
+ Send (ev->Sender , new NMon::TEvHttpInfoRes (response, 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
508
484
return ;
509
485
}
510
486
TString path (" /" + msg->Request .GetPage ()->Path + msg->Request .GetPathInfo ());
@@ -608,11 +584,15 @@ void TViewer::FillCORS(TStringBuilder& stream, const TRequestState& request) {
608
584
} else if (request && request->Request .GetHeaders ().HasHeader (" Origin" )) {
609
585
origin = request->Request .GetHeader (" Origin" );
610
586
}
587
+ if (origin.empty ()) {
588
+ origin = " *" ;
589
+ }
611
590
if (origin) {
612
591
stream << " Access-Control-Allow-Origin: " << origin << " \r\n "
613
592
<< " Access-Control-Allow-Credentials: true\r\n "
614
593
<< " Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n "
615
- << " Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n " ;
594
+ << " Access-Control-Allow-Methods: OPTIONS, GET, POST, DELETE\r\n "
595
+ << " Allow: OPTIONS, GET, POST, DELETE\r\n " ;
616
596
}
617
597
}
618
598
0 commit comments