'Generic Commit'
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
namespace simple_object_storage {
|
||||
|
||||
Server* Server::instance_ = nullptr;
|
||||
std::mutex Server::instance_mutex_;
|
||||
|
||||
|
||||
bool Server::init_db() {
|
||||
@@ -145,6 +146,11 @@ bool Server::start() {
|
||||
drogon::app().addListener(config_.host, config_.port);
|
||||
drogon::app().setThreadNum(16);
|
||||
|
||||
// Set security limits (allowing for 1GB+ files for testing)
|
||||
drogon::app().setClientMaxBodySize(2ULL * 1024 * 1024 * 1024); // 2GB max body size
|
||||
drogon::app().setClientMaxMemoryBodySize(100 * 1024 * 1024); // 100MB max memory body (keep this lower)
|
||||
drogon::app().enableGzip(true); // Enable compression
|
||||
|
||||
// Start the server
|
||||
try {
|
||||
drogon::app().run();
|
||||
@@ -165,9 +171,11 @@ void Server::stop() {
|
||||
}
|
||||
|
||||
void Server::setup_routes() {
|
||||
// Configure global filters for CORS
|
||||
// Configure CORS only for requests with Origin header
|
||||
drogon::app().registerPostHandlingAdvice([this](const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) {
|
||||
add_cors_headers(req, resp);
|
||||
if (!req->getHeader("Origin").empty()) {
|
||||
add_cors_headers(req, resp);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle OPTIONS requests for CORS preflight
|
||||
@@ -175,6 +183,7 @@ void Server::setup_routes() {
|
||||
std::function<void(const drogon::HttpResponsePtr &)> &&callback) {
|
||||
handle_cors_preflight(req, std::move(callback));
|
||||
}, {}, "OPTIONS");
|
||||
|
||||
}
|
||||
|
||||
void Server::handle_cors_preflight(const drogon::HttpRequestPtr& req, std::function<void(const drogon::HttpResponsePtr &)>&& callback) {
|
||||
|
Reference in New Issue
Block a user