February 09

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

img

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.

February 09

In the files, dt specified the path to the files from the root /style.css and now, with any path from the root, files are loaded into the page, instead of style.css. My mistake.