In the https://github.com/metosin/reitit/blob/7f7d6e22565362ac2b1c21a413865bab38438bac/examples/frontend-auth/src/frontend/core.cljs the main-view
screen ensures that protected routes aren’t rendered. However, with this implementation, if the user clicks “items” link the URL will still read http://0.0.0.0:3449/#/items while showing the login screen. Is there a recommendation on where to replace
history so the URL also reads something like http://0.0.0.0:3449/#/login?
i'm trying to put certain routes under a subdomain but can't see any way to route based on host. is this at all possible using pedestal without running two separate servers?
@apa512 not supported out-of-the-box. But you could create a small pre-processor to do it.
something like: 1) create a router with forced bracket-syntax, full urls 2) read the compiled routes, split based on virtual host and create two routers & ring/http handlers and route to correct one based on virtual host
1 could just be arbitrary route data key too, like {:vhosts #{"dev" "test"}}.
should not be more than 10 lines on top of the current apis.
cool, does that mean ring handlers are compatible with pedestal?
Hi All. Does anyone have a really basic example of handling csrf in reitit. I've added wrap-anti-forgery to my middleware but everytime I do a post I get an invalid csrf token. If someone has an example of this working in reitit I'd be really grateful. Thanks.
Thought I'd reply to my own comment as I found my issue. In my app definition I'd added the :middleware wrap-session against ring/router when it should have been ring/ring-handler. The implication being that I never defined a session so my csrf wouldn't work.
@apa512 oh, pedestal. The same custom code should be in the routing-ibterceptor then (from reitit.pedestal
)
@ikitommi thanks, i will check it out
[metosin/reitit "0.5.0-SNAPSHOT"]
is on clojars, here’s the CHANGELOG: https://github.com/metosin/reitit/blob/master/CHANGELOG.md#050-snapshot
So just changing the version to [metosin/reitit "0.5.0-SNAPSHOT"]
throwed a java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase
thank you Jackson. Could you list your (transitiv) dependencies?
e.g. lein deps :tree
or such
sure
Maven sucks at this: you have a direct dependency to Cheshire, which uses older version of Jackson, which is the shortest path, overriding the version from Jsonista, which, reitit uses (much faster). Jackson seems to break internally on every version.
[cheshire "5.8.1"] -> [com.fasterxml.jackson.core/jackson-core "2.9.6"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[org.webjars/webjars-locator "0.36"] -> [com.fasterxml.jackson.core/jackson-databind "2.9.8"] -> [com.fasterxml.jackson.core/jackson-core "2.9.8"]
[org.webjars/webjars-locator "0.36"] -> [org.webjars/webjars-locator-core "0.37"] -> [com.fasterxml.jackson.core/jackson-core "2.9.8"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
that says it all.
only way to fix that is:
a) get Cheshre to use the latest version
b) manually add [com.fasterxml.jackson.core/jackson-core "2.11.0"]
as dependency, it’s the shortest path and overrides everything
cool will give that a try thanks
hmm... i did both and still get the same exception
i updated Cheshre and manually added [com.fasterxml.jackson.core/jackson-core "2.11.0"]
what does the deps tree say now?
ha wow you move fast
thanks
Almost would like to rollback the swagger-ui back to 2.*. Not a fan of the new one.