(注意,我使用的是 Reagent、Secretary 和 Compojure(以及其他))
我想创建一条路线/sectest/:id
,如果我将浏览器指向该路线,我会收到以下错误:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3449/sectest/css/site.css".
asdf:1
Refused to execute script from 'http://localhost:3449/sectest/js/app.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
但是,如果我单击浏览器中导航到该路线的链接,它就可以正常工作...
这是相关的代码:
客户端:
(secretary/defroute "/sectest/:id" [id]
(do
(js/console.log (str "Hi " id))
(session/put! :current-page #'my-page)))
服务器端:
(defroutes routes
(GET "*" [] loading-page) ;this anticipates client-side routing only
(GET "/cards" [] cards-page)
(resources "/")
(not-found "Not Found"))
(def app (wrap-middleware #'routes))
因此,以下链接将我带到my-page
,并且控制台打印"Hi asdf"
得很好:
[:div [:a {:href "/sectest/asdf"} "SECTEST"]]
但是如果我输入http://localhost:3449/sectest/asdf
,我会得到一个错误,而且我似乎无法追踪它。我怀疑这可能与试图查找位于 , 的资源的代码有关/sectest
(它不应该),但我无法确认这一点或弄清楚如何使用它......我是clojure 的新手,如果我在某些方面非常无知,请原谅,有什么想法吗?