Skip to content

Commit a024cd0

Browse files
committed
Added a log directory for UI debugging.
1 parent a681a22 commit a024cd0

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

api/src/filters/CorsFilter.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ void CorsFilter::doFilter(const drogon::HttpRequestPtr& req,
1010
drogon::FilterChainCallback&& fccb) {
1111
API_LOG_DEBUG("Processing CORS request for path: {}", req->getPath());
1212

13-
// Create response for handling CORS
14-
auto resp = drogon::HttpResponse::newHttpResponse();
15-
16-
// Add CORS headers matching your config
17-
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
18-
resp->addHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
19-
resp->addHeader("Access-Control-Allow-Headers", "Content-Type,Authorization");
20-
resp->addHeader("Access-Control-Max-Age", "86400");
21-
22-
// Handle preflight request
2313
if (req->getMethodString() == "OPTIONS") {
14+
// Handle preflight request
2415
API_LOG_DEBUG("Handling OPTIONS preflight request");
25-
resp->setStatusCode(drogon::k204NoContent);
16+
auto resp = drogon::HttpResponse::newHttpResponse();
17+
18+
// Add CORS headers for preflight
19+
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
20+
resp->addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
21+
resp->addHeader("Access-Control-Allow-Headers", "Content-Type");
22+
resp->addHeader("Access-Control-Max-Age", "86400");
23+
24+
// Important: Set status 200 for OPTIONS
25+
resp->setStatusCode(drogon::k200OK);
2626
fcb(resp);
2727
return;
2828
}
2929

30-
// For non-OPTIONS requests, add CORS headers to the response
31-
req->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
32-
req->addHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
33-
req->addHeader("Access-Control-Allow-Headers", "Content-Type,Authorization");
34-
req->addHeader("Access-Control-Max-Age", "86400");
35-
30+
// For non-OPTIONS requests
31+
auto resp = drogon::HttpResponse::newHttpResponse();
32+
resp->addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
33+
resp->addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
34+
resp->addHeader("Access-Control-Allow-Headers", "Content-Type");
35+
3636
// Continue with the request chain
3737
fccb();
3838
}

logs/api.241215-024616.000000.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20241215 02:46:16.053108 UTC 10367 WARN SIGINT signal received. - HttpAppFrameworkImpl.cc:186

logs/api.241215-025018.000000.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20241215 02:50:18.483464 UTC 10621 WARN SIGINT signal received. - HttpAppFrameworkImpl.cc:186

logs/api_2024-12-14.log

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@
33
[2024-12-14 20:32:06.597] [API] [info] [10367] Starting Quantitative Finance API server
44
[2024-12-14 20:32:06.597] [API] [info] [10367] Server configuration loaded successfully
55
[2024-12-14 20:32:06.597] [API] [info] [10367] Starting server on port 8080
6+
[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
7+
[2024-12-14 21:39:18.125] [API] [info] [10370] Black-Scholes calculation completed. Result: 10.450583572185565
8+
[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
9+
[2024-12-14 21:43:16.955] [API] [info] [10370] Black-Scholes calculation completed. Result: 10.450583572185565
10+
[2024-12-14 21:48:04.982] [API] [info] [10621] Starting Quantitative Finance API server
11+
[2024-12-14 21:48:04.983] [API] [info] [10621] Server configuration loaded successfully
12+
[2024-12-14 21:48:04.983] [API] [info] [10621] Starting server on port 8080
13+
[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
14+
[2024-12-14 21:48:14.305] [API] [info] [10625] Black-Scholes calculation completed. Result: 10.450583572185565
15+
[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
16+
[2024-12-14 21:48:52.611] [API] [info] [10630] Binomial Tree calculation completed. Result: 10.430611662249113

0 commit comments

Comments
 (0)