This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-21
Channels
- # announcements (5)
- # babashka (9)
- # beginners (84)
- # calva (47)
- # clara (3)
- # clj-kondo (2)
- # clojars (8)
- # clojure-australia (3)
- # clojure-europe (3)
- # clojure-spec (1)
- # clojurescript (5)
- # conjure (6)
- # cursive (7)
- # datahike (3)
- # events (2)
- # helix (1)
- # lsp (217)
- # luminus (4)
- # malli (18)
- # meander (23)
- # membrane (12)
- # off-topic (26)
- # pathom (12)
- # reagent (44)
- # releases (1)
- # rewrite-clj (2)
- # shadow-cljs (19)
- # sql (17)
- # xtdb (6)
I have a shadow-cljs project using a node-script build, I'm using shadow-cljs node-repl then connecting and trying evaluate my file that has npm imports like ["robotjs" as robo] when I try and evaluate the file I'm getting clojure.core.spec complaining about that, where am I going wrong?
ah looks like I had to do (shadow/node-repl) whilst inside the repl
@theller I don't know, if this came up earlier. For some time, I was unable to load the development version of our ClojureScript project on localhost in Chromium. It worked in Firefox, but was rather slow. I didn't know at all, what caused it. So I tried to gather some data about it. I cleared the cache of Chromium (deleted ~/.cache/chromium) and this helped a few times but the problem always returned. I have resorted to deleting of the build directory of shadow-cljs. The result was that the development version of our project loaded immediately in Chromium and Firefox as well. I don't have any further data, just wanted to let you know.
Hello,
I’m trying to setup custom response headers in order to do a cross-origin request during development. I’ve been reading [the user guide](https://shadow-cljs.github.io/docs/UsersGuide.html) and [a stackoverflow question](https://stackoverflow.com/questions/65907176/how-to-properly-setup-shadow-cljs-for-hot-reload) but it seems the headers only apply to the shadow-cljs “dashboard” server (eg. 9630), not the app itself.
I tried the following so far:
- wrapping shadow.http.push-state/handle
and calling the wrapper in :dev-http
. Same result when overriding :push-state/headers
- setting :devtools :http-handler
, again pointing at my wrapper
I just wanted to ask here before going through the source, maybe there’s something i misunderstood entirely from the docs.
I’m starting the server up through emacs cljs-jack-in with
npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.9 server
;; dev/custom_handler.clj
(ns custom-handler
(:require [shadow.http.push-state :refer [handle]]))
(defn handle-wrapper
[req]
(handle (assoc-in req
[:http-config :push-state/headers]
{"conten-type" "text/html; charset=utf-8"
"access-control-allow-origin" "*"})))
;; shadow-cljs.edn
;; shadow-cljs 2.11.7
;; clojurescript 1.10.773
{:deps {:aliases [:dev :shadow :cljc]}
:nrepl {:port 8777
:middleware [refactor-nrepl.middleware/wrap-refactor]}
:dev-http {8281 {
:root "resources/public"
:push-state/headers {"access-control-allow-origin" "*"}
}
}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn remyrd.rock-n-call-frontend.core/init}}
:devtools {:http-root "resources/public"
:http-port 8280
:http-handler custom-handler/handle-wrapper
:preloads [devtools.preload]
}}}}
basically as soon as you want to do something like this you should be using your own http server instead
the handler isn't supposed to modify the request coming in. instead it should modify the response
(defn handle-wrapper
[req]
(-> req
(handle)
(update :headers merge
{"access-control-allow-origin" "*"})))
Right, silly me it should’ve gone in the response. I agree I should be using my own http server, for now i’m just doodling and I needed this data from an external api.
Well i’m trying to figure out what is the best way to serve cross-origin content on a static webpage, probably I’m forcing this approach but I wanted to avoid spinning up a server