Skip to content

Commit cf27205

Browse files
authored
Relative ping basepath (#40)
Solution for #34
1 parent 65a95fd commit cf27205

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/httpserver_extension.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
290290

291291
if (base_path_env && base_path_env[0] == '/' && strlen(base_path_env) > 1) {
292292
base_path = std::string(base_path_env);
293+
// Ensure trailing slash for consistent endpoint joining
294+
if (base_path.back() != '/') {
295+
base_path += '/';
296+
}
293297
}
294298

295299
// CORS Preflight
@@ -312,7 +316,8 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
312316
global_state.server->Post(base_path, HandleHttpRequest);
313317

314318
// Health check endpoint
315-
global_state.server->Get("/ping", [](const duckdb_httplib_openssl::Request& req, duckdb_httplib_openssl::Response& res) {
319+
// Health check endpoint, now relative to base_path
320+
global_state.server->Get(base_path + "ping", [](const duckdb_httplib_openssl::Request& req, duckdb_httplib_openssl::Response& res) {
316321
res.set_content("OK", "text/plain");
317322
});
318323

0 commit comments

Comments
 (0)