I want to serve the following route for any GET request path so that I can use a frontend routing library instead (react-router).
(GET "/" [] (resource-response "index.html" {:root "public"}))
This it what I have tried:
(GET "/*" [] (resource-response "index.html" {:root "public"}))
(rfn [] (resource-response "index.html" {:root "public"}))
(GET "/:any{.*}" [] (resource-response "index.html" {:root "public"}))
(GET "/*" [] (ring.util.response/content-type
(ring.util.response/resource-response "index.html" {:root "public"}) "text/html"))
(GET "/*" [] (clojure.java.io/resource "public/index.html"))
They all give the same error:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:5000/index.css".
bundle.js:1 Uncaught SyntaxError: Unexpected token <
And the Unexpected token is the first <
in index.html
So my question is how can I adapt my Compojure/Ring/Immutant stack to play nice with react-router?
UPDATE: I have also tried the following midleware, to change all request to the root but with no luck:
(defn wrap-dir-index [handler]
(fn [req]
(handler
(assoc req :uri "/"))))