Skip to content

Commit

Permalink
Added a log directory for UI debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
tembolo1284 committed Dec 15, 2024
1 parent a681a22 commit a024cd0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
34 changes: 17 additions & 17 deletions api/src/filters/CorsFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ void CorsFilter::doFilter(const drogon::HttpRequestPtr& req,
drogon::FilterChainCallback&& fccb) {
API_LOG_DEBUG("Processing CORS request for path: {}", req->getPath());

// Create response for handling CORS
auto resp = drogon::HttpResponse::newHttpResponse();

// Add CORS headers matching your config
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
resp->addHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
resp->addHeader("Access-Control-Allow-Headers", "Content-Type,Authorization");
resp->addHeader("Access-Control-Max-Age", "86400");

// Handle preflight request
if (req->getMethodString() == "OPTIONS") {
// Handle preflight request
API_LOG_DEBUG("Handling OPTIONS preflight request");
resp->setStatusCode(drogon::k204NoContent);
auto resp = drogon::HttpResponse::newHttpResponse();

// Add CORS headers for preflight
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
resp->addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
resp->addHeader("Access-Control-Allow-Headers", "Content-Type");
resp->addHeader("Access-Control-Max-Age", "86400");

// Important: Set status 200 for OPTIONS
resp->setStatusCode(drogon::k200OK);
fcb(resp);
return;
}

// For non-OPTIONS requests, add CORS headers to the response
req->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
req->addHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
req->addHeader("Access-Control-Allow-Headers", "Content-Type,Authorization");
req->addHeader("Access-Control-Max-Age", "86400");

// For non-OPTIONS requests
auto resp = drogon::HttpResponse::newHttpResponse();
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
resp->addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
resp->addHeader("Access-Control-Allow-Headers", "Content-Type");
// Continue with the request chain
fccb();
}
Expand Down
1 change: 1 addition & 0 deletions logs/api.241215-024616.000000.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20241215 02:46:16.053108 UTC 10367 WARN SIGINT signal received. - HttpAppFrameworkImpl.cc:186
1 change: 1 addition & 0 deletions logs/api.241215-025018.000000.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20241215 02:50:18.483464 UTC 10621 WARN SIGINT signal received. - HttpAppFrameworkImpl.cc:186
11 changes: 11 additions & 0 deletions logs/api_2024-12-14.log
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
[2024-12-14 20:32:06.597] [API] [info] [10367] Starting Quantitative Finance API server
[2024-12-14 20:32:06.597] [API] [info] [10367] Server configuration loaded successfully
[2024-12-14 20:32:06.597] [API] [info] [10367] Starting server on port 8080
[2024-12-14 21:39:18.125] [API] [info] [10370] Calculating Black-Scholes price with parameters: spot=100, strike=100, r=0.05, t=1, vol=0.2, is_call=true
[2024-12-14 21:39:18.125] [API] [info] [10370] Black-Scholes calculation completed. Result: 10.450583572185565
[2024-12-14 21:43:16.955] [API] [info] [10370] Calculating Black-Scholes price with parameters: spot=100, strike=100, r=0.05, t=1, vol=0.2, is_call=true
[2024-12-14 21:43:16.955] [API] [info] [10370] Black-Scholes calculation completed. Result: 10.450583572185565
[2024-12-14 21:48:04.982] [API] [info] [10621] Starting Quantitative Finance API server
[2024-12-14 21:48:04.983] [API] [info] [10621] Server configuration loaded successfully
[2024-12-14 21:48:04.983] [API] [info] [10621] Starting server on port 8080
[2024-12-14 21:48:14.305] [API] [info] [10625] Calculating Black-Scholes price with parameters: spot=100, strike=100, r=0.05, t=1, vol=0.2, is_call=true
[2024-12-14 21:48:14.305] [API] [info] [10625] Black-Scholes calculation completed. Result: 10.450583572185565
[2024-12-14 21:48:52.611] [API] [info] [10630] Calculating Binomial Tree price with parameters: spot=100, strike=100, r=0.05, t=1, vol=0.2, is_call=true, steps=100
[2024-12-14 21:48:52.611] [API] [info] [10630] Binomial Tree calculation completed. Result: 10.430611662249113

0 comments on commit a024cd0

Please sign in to comment.