Index.html
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="assets/css/material-design-iconic-font.min.css">
<link rel="stylesheet" href="assets/css/re-com.css">
</head>
<body>
<script src="js/app.js" type="text/javascript"></script>
</body>
</html>
Compojure routes
(defn root-handler [_]
(resp/content-type (resp/resource-response "/index.html" {:root "public"}) "text/html"))
(defroutes app-routes
(GET "/" [] root-handler)
(context "/fake" []
(GET "/" [] (str "<h1>" "Meaningless URL just to test we get a response" "</h1>"))
(GET "/sub" [] (str "<h1>" "Meaningless sub level URL just to test we get a response" "</h1>"))
)
(ANY "*" [] root-handler)
)
(def app
(->
app-routes
(wrap-reload)
(wrap-authentication auth-backend)
(prone/wrap-exceptions)
; wrap-defaults adds lots of standard middleware such as wrap_params, wrap_cookies etc
(wrap-defaults site-defaults)))
I have an index.html file and some routes as defined above. When I navigate to localhost:3000/fake or localhost:3000/fake/sub
the "meaningles ..." text is rendered as I would expect.
If I navigate to something like localhost:3000/employees my (ANY "*" [] root-handler) route renders the index.html and then the my client side javascript kicks in and renders correctly.
However If navigate to something like localhost:3000/employees/sub (note a "sub" route of a employees) then I get errors in the Chrome console stating that
localhost:3000/employees/assets/css/material-design-iconic-font.min.css cannot be found.
The browser now seems to think that localhost:3000/employees/ is the root and not localhost:3000/
How can I fix that?