@@ -325,8 +325,16 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
325
325
global_state.is_running = true ;
326
326
global_state.auth_token = auth.GetString ();
327
327
328
+ // Custom basepath, defaults to root /
329
+ const char * base_path_env = std::getenv (" DUCKDB_HTTPSERVER_BASEPATH" );
330
+ std::string base_path = " /" ;
331
+
332
+ if (base_path_env && base_path_env[0 ] == ' /' && strlen (base_path_env) > 1 ) {
333
+ base_path = std::string (base_path_env);
334
+ }
335
+
328
336
// CORS Preflight
329
- global_state.server ->Options (" / " ,
337
+ global_state.server ->Options (base_path ,
330
338
[](const duckdb_httplib_openssl::Request& /* req*/ , duckdb_httplib_openssl::Response& res) {
331
339
res.set_header (" Access-Control-Allow-Methods" , " POST, GET, OPTIONS" );
332
340
res.set_header (" Content-Type" , " text/html; charset=utf-8" );
@@ -341,8 +349,8 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
341
349
global_state.allocator = make_uniq<Allocator>();
342
350
343
351
// Handle GET and POST requests
344
- global_state.server ->Get (" / " , HandleHttpRequest);
345
- global_state.server ->Post (" / " , HandleHttpRequest);
352
+ global_state.server ->Get (base_path , HandleHttpRequest);
353
+ global_state.server ->Post (base_path , HandleHttpRequest);
346
354
347
355
// Health check endpoint
348
356
global_state.server ->Get (" /ping" , [](const duckdb_httplib_openssl::Request& req, duckdb_httplib_openssl::Response& res) {
0 commit comments