Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Update pre-routing handler in httpserver.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Mar 26, 2024
1 parent dbfebd9 commit 9fa7cc3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/translation-service/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ void start_http_server()
}
global_context.svr = new httplib::Server();

global_context.svr->set_pre_routing_handler([](const httplib::Request&, httplib::Response& res) {
res.set_header("Access-Control-Allow-Origin", "*");
res.set_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.set_header("Access-Control-Allow-Headers", "Content-Type, Authorization");
return httplib::Server::HandlerResponse::Unhandled;
});
global_context.svr->set_pre_routing_handler([](const httplib::Request &,
httplib::Response &res) {
res.set_header("Access-Control-Allow-Origin", "*");
res.set_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.set_header("Access-Control-Allow-Headers",
"Content-Type, Authorization");
return httplib::Server::HandlerResponse::Unhandled;
});

// set an echo handler
global_context.svr->Post("/echo", [](const httplib::Request &req,
Expand Down

0 comments on commit 9fa7cc3

Please sign in to comment.