This commit is contained in:
chatlanin 2024-08-04 12:19:03 +03:00
parent c3d564b618
commit 09d3025003
2 changed files with 9 additions and 3 deletions

View File

@ -73,17 +73,24 @@ namespace trs
} }
} }
void set_api_url(std::string url)
{
API_URL = url;
}
private: private:
std::string m_service_name; std::string m_service_name;
bool m_log_to_console { true }; bool m_log_to_console { true };
function_manager<transaction> m_function_manager; function_manager<transaction> m_function_manager;
inspector<transaction> m_inspector; inspector<transaction> m_inspector;
std::string API_URL { "/" };
private: private:
void set_CORS() void set_CORS()
{ {
Options(R"(\*)", [](const auto& req, auto& res) { res.set_header("Allow", "POST, HEAD, OPTIONS"); }); Options(R"(\*)", [](const auto& req, auto& res) { res.set_header("Allow", "POST, HEAD, OPTIONS"); });
Options(var::API_URL, [](const auto& req, auto& res) Options(API_URL, [](const auto& req, auto& res)
{ {
res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Origin", "*");
res.set_header("Allow", "POST, HEAD, OPTIONS"); res.set_header("Allow", "POST, HEAD, OPTIONS");
@ -94,7 +101,7 @@ namespace trs
void set_post() void set_post()
{ {
Post(var::API_URL, [&](const httplib::Request& req, httplib::Response& res) { Post(API_URL, [&](const httplib::Request& req, httplib::Response& res) {
res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Origin", "*");
res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Headers", "*");
res.set_header("Access-Control-Allow-Methods", "POST"); res.set_header("Access-Control-Allow-Methods", "POST");

View File

@ -6,7 +6,6 @@ namespace trs::var
{ {
inline const int PORT = 5000; inline const int PORT = 5000;
inline const std::string HOST = "0.0.0.0"; inline const std::string HOST = "0.0.0.0";
inline const std::string API_URL = "/";
inline const std::string ALIEN_SYSTEM_ERROR = "is alien system error it can be very dangerous!!! good luck my friend!"; inline const std::string ALIEN_SYSTEM_ERROR = "is alien system error it can be very dangerous!!! good luck my friend!";
inline const std::string NO_VALID_DATA = "no valid data"; inline const std::string NO_VALID_DATA = "no valid data";