@@ -431,8 +431,31 @@ namespace torrents
431431 {
432432 if (!ecode)
433433 {
434- if (m_Request.method () == boost::beast::http::verb::post )
434+ if (m_Request.method () == boost::beast::http::verb::options )
435435 {
436+ m_Response.version (11 ); // HTTP/1.1
437+ m_Response.result (204 );
438+ m_Response.set (boost::beast::http::field::access_control_allow_origin, " *" );
439+ m_Response.set (boost::beast::http::field::access_control_allow_methods, " GET, POST, OPTIONS" );
440+ m_Response.set (boost::beast::http::field::access_control_allow_headers, " Content-Type, Authorization" );
441+
442+ m_Response.keep_alive (m_Request.keep_alive ());
443+ m_Response.prepare_payload ();
444+ boost::beast::http::async_write (m_Socket, m_Response,
445+ [s = shared_from_this ()](const boost::system::error_code& ecode, size_t bytes_transferred)
446+ {
447+ if (ecode)
448+ LogPrint (eLogWarning, " TorrentsRPC: Failed to send response: " , ecode.message ());
449+ });
450+ }
451+ else if (m_Request.method () == boost::beast::http::verb::post )
452+ {
453+ m_Response.set (
454+ boost::beast::http::field::access_control_allow_origin,
455+ " *" );
456+ m_Response.set (
457+ boost::beast::http::field::access_control_allow_headers,
458+ " Content-Type, Authorization" );
436459 auto path = m_Request.target ();
437460 auto tunnel = m_Server.GetTunnel ( {path.data (), path.size ()}); // boost::beast::string_view to std::string_view
438461 if (tunnel)
0 commit comments