@@ -5268,42 +5268,6 @@ int main(int argc, char ** argv) {
52685268 svr->Get (params.api_prefix + " /slots" , handle_slots);
52695269 svr->Post (params.api_prefix + " /slots/:id_slot" , handle_slots_action);
52705270
5271- // SPA fallback route - serve index.html for any route that doesn't match API endpoints
5272- // This enables client-side routing for dynamic routes like /chat/[id]
5273- if (params.webui && params.public_path .empty ()) {
5274- // Only add fallback when using embedded static files
5275- svr->Get (" .*" , [](const httplib::Request & req, httplib::Response & res) {
5276- // Skip API routes - they should have been handled above
5277- if (req.path .find (" /v1/" ) != std::string::npos ||
5278- req.path .find (" /health" ) != std::string::npos ||
5279- req.path .find (" /metrics" ) != std::string::npos ||
5280- req.path .find (" /props" ) != std::string::npos ||
5281- req.path .find (" /models" ) != std::string::npos ||
5282- req.path .find (" /api/tags" ) != std::string::npos ||
5283- req.path .find (" /completions" ) != std::string::npos ||
5284- req.path .find (" /chat/completions" ) != std::string::npos ||
5285- req.path .find (" /embeddings" ) != std::string::npos ||
5286- req.path .find (" /tokenize" ) != std::string::npos ||
5287- req.path .find (" /detokenize" ) != std::string::npos ||
5288- req.path .find (" /lora-adapters" ) != std::string::npos ||
5289- req.path .find (" /slots" ) != std::string::npos) {
5290- return false ; // Let other handlers process API routes
5291- }
5292-
5293- // Serve index.html for all other routes (SPA fallback)
5294- if (req.get_header_value (" Accept-Encoding" ).find (" gzip" ) == std::string::npos) {
5295- res.set_content (" Error: gzip is not supported by this browser" , " text/plain" );
5296- } else {
5297- res.set_header (" Content-Encoding" , " gzip" );
5298- // COEP and COOP headers, required by pyodide (python interpreter)
5299- res.set_header (" Cross-Origin-Embedder-Policy" , " require-corp" );
5300- res.set_header (" Cross-Origin-Opener-Policy" , " same-origin" );
5301- res.set_content (reinterpret_cast <const char *>(index_html_gz), index_html_gz_len, " text/html; charset=utf-8" );
5302- }
5303- return false ;
5304- });
5305- }
5306-
53075271 //
53085272 // Start the server
53095273 //
0 commit comments