diff --git a/src/trs/trs.hpp b/src/trs/trs.hpp index eadef58..f3686df 100644 --- a/src/trs/trs.hpp +++ b/src/trs/trs.hpp @@ -73,17 +73,24 @@ namespace trs } } + void set_api_url(std::string url) + { + API_URL = url; + } + private: std::string m_service_name; bool m_log_to_console { true }; function_manager m_function_manager; inspector m_inspector; + std::string API_URL { "/" }; + private: void set_CORS() { 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("Allow", "POST, HEAD, OPTIONS"); @@ -94,7 +101,7 @@ namespace trs 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-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "POST"); diff --git a/src/trs/utils/var.hpp b/src/trs/utils/var.hpp index d01c16a..0dbe388 100644 --- a/src/trs/utils/var.hpp +++ b/src/trs/utils/var.hpp @@ -6,7 +6,6 @@ namespace trs::var { inline const int PORT = 5000; 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 NO_VALID_DATA = "no valid data";