Is there a universal way to access files (styles, scripts) for nested paths?
string datapath = "./";
auto router = new URLRouter;
router.get("/", &getReq);
router.get("*", serveStaticFiles(buildPath(datapath, "public")));
router.get("*", serveStaticFiles(buildPath(datapath, "images")));
router.get("*", serveStaticFiles(buildPath(datapath, "js")));
auto profile = new URLRouter("/profile");
profile.get("/", &getReqProfile);
profile.get("/test", &getReqProfile);
profile.get("*", serveStaticFiles(buildPath(datapath, "public")));
profile.get("*", serveStaticFiles(buildPath(datapath, "images")));
profile.get("*", serveStaticFiles(buildPath(datapath, "js")));
router.any("*", profile);
// / -> OK
// /profile -> 404
// /profile/ -> OK without css, js
// /profile/test -> OK without css, js
Page 404 also does not load styles if the path is similar to /abc/asd/asd
, but if the path is single-level, then the styles are loaded.