This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-24
Channels
- # announcements (12)
- # aws (11)
- # babashka (1)
- # beginners (73)
- # cider (4)
- # clj-kondo (2)
- # cljsrn (4)
- # clojars (2)
- # clojure (68)
- # clojure-europe (8)
- # clojure-nl (5)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (29)
- # clojurescript (41)
- # conjure (22)
- # datomic (33)
- # docker (58)
- # duct (3)
- # emacs (8)
- # events (1)
- # expound (3)
- # figwheel-main (5)
- # fulcro (33)
- # graphql (2)
- # kaocha (2)
- # lambdaisland (39)
- # leiningen (1)
- # nrepl (49)
- # nyc (1)
- # off-topic (77)
- # pathom (1)
- # re-frame (33)
- # reagent (28)
- # reitit (1)
- # rewrite-clj (2)
- # shadow-cljs (195)
- # spacemacs (1)
- # sql (60)
- # tools-deps (13)
- # vim (18)
- # xtdb (46)
Hey guys, I got a quick question. I have made a reitit backend that runs on localhost:3000. Now I'm building a frontend with reagent that runs on localhost:8280. I'm trying to make http(ajax) requests to http://127.0.0.1:3000/apicall.... from my reagent frontend. however I keep getting failed requests. I think I forgot to setup some proxy settings or something. When I invoke the the same request through Insomnia it all works as exected.
Is it not CORS? Do you have the network logs from your browser?
yeah could be, I also added some additional headers to the request, maybe they are incomplete
keeps getting status 0
in the response as described in: https://github.com/Day8/re-frame-http-fx
so yeah seems like CORS
Just look at the JS console - it should have all details. You cannot say anything by just "status 0" alone.
I'll look for it tonight/tomorrow. cant look right now 😉 thx
The console shows that the response is returned correctly,
So I fixed it by installing an addon to my broswer (cors everywhere).
I think it is a problem with my backend reitit app
cant really find how to enable cors headers / middleware for all requests
> So I fixed it by installing an addon to my broswer (cors everywhere). That sounds scary. Basically to get "CORS everywhere" to work you'd need to proxy all requests and add headers, which to me seems to indicate that all your traffic is now going through a middle-man. You should check the implementation of this extension before you continue with it
I think I need to add some cors support to my reitit backend
traced it down to it
to enable CORS you'd just have to return a specific set of headers in your http requests. So setting Allow-Access-Control-Origin
to localhost:8280
(frontend) should do the trick for GET requests at least
my backend does not add them yet
so ill check that 🙂
at least i know the ajax calls are setup correctly now
yeah, true. For the future: you can start Chrome with --disable-web-security
to disable CORS checks, make sure you use a new profile + don't visit your bank and such with it disabled though.
Alright; I think I have fixed it in the cleanest possible way: In my backend (reitit) I added a dependency to a package called: ring-cors, then I added a middleware handler that wraps the headers:
(defn cors-wrapper
[handler]
(wrap-cors handler :access-control-allow-origin [#""]
:access-control-allow-methods [:get :put :post :delete]))
and added this handler in the reitit middle ware section:
:middleware [
;; wrap cors headers
cors-wrapper
;; swagger feature
swagger/swagger-feature
;; other middleware
.....
]
hello is it possible that some react native/react components will rerender only when setState is called and not otherwise? Are there any examples of reagent components using setState instead of ratoms?
You could check reagent 1.0 (alpha) documentation, especially the :f> keyword
https://github.com/wuxudong/react-native-charts-wrapper/blob/master/Example/app/LiveUpdateChartScreen.js i dont think i can use hooks for this example i need component