This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-27
Channels
- # announcements (47)
- # babashka (36)
- # beginners (7)
- # biff (34)
- # calva (9)
- # cider (5)
- # clj-http (13)
- # clj-kondo (24)
- # cljs-dev (9)
- # clojure (146)
- # clojure-austin (1)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (2)
- # clojurescript (4)
- # clr (1)
- # core-async (9)
- # cursive (11)
- # datomic (6)
- # emacs (17)
- # events (3)
- # fulcro (45)
- # graphql (7)
- # helix (1)
- # hyperfiddle (28)
- # java (1)
- # london-clojurians (1)
- # lsp (75)
- # malli (1)
- # membrane (35)
- # reitit (6)
- # releases (1)
- # shadow-cljs (48)
- # tools-build (5)
- # tools-deps (27)
Hello everyone! When starting the development server in shadow-cljs, index.html
is served but access to the /
url does not resolve to /index.html
, yielding a 500 error (and an exception log coming from shadow-undertow java.lang.ClassCastException: class clojure.lang.Keyword cannot be cast to class java.lang.String
coming from set-headers
meaning that something tried to supply headers as keywords). Nothing major but I couldn't find the reason for this small annoyance, if anyone can share a pointer I'd happily do the necessary patching.
and what is the full stacktrace? that should give you a hint where it is coming from
I have an additional handler but if I remove it the problem remains (tried that already). Here is the full stack trace: https://gist.github.com/pyr/76bc334e12ab4d97dac753b33289391a
what is this handler doing? I mean you are likely setting {:status 200 {:headers {:foo "whatever"}} :body ...}
in it? or maybe some middleware it uses?
guess the handlers is done at this point, so thats why its not showing up in the stacktrace
OK yes this is likely happening on the error path. I'll fix that. Regardless, without the handler I still get a 404 on /, is there a way to tell shadow-undertow to look for index.html in that case?
the default will serve index.html. say :dev-http {3000 "public"}
accessing localhost:3000 will look for public/index.html
the push-state handler will do that though, so if you have a custom handler it is responsible for serving that
understood, so the fact that used a map push-state didn't get used, it's then up to my API to perform the redirect
if you want that behavior back you can set :use-index-files true
in the server config
as in :dev-http {3000 {:root "public" :use-index-files true :handler your.thing/handler}}
only really make sense if you have a custom handler, the default should behave as expected
:dev-http {8000 {:root "public/"}}
should server public/index.html
on localhost:8000
but it might be OS/FS dependent whether it does. maybe needs to be :dev-http {8000 {:root "public"}}
I was confused by push-state, since I was testing with curl, I still so not-found on / whereas without my handler the browser would indeed see its state pushed to /index.html
if you write a custom handler you can call (shadow.http.push-state/handle req)
if you own handler is not interested tohandle it
sorry for the mixup in any case, and thanks for the help. I've got plenty of options now 🙂
var Select = (0, _stateManager.default)(_Select.default);
Select.Async = _Async.default;
Select.AsyncCreatable = _AsyncCreatable.default;
Select.Creatable = _Creatable.default;
Select.SelectBase = _Select.default;
Select.createFilter = _filters.createFilter;
Select.components = _index.components;
Select.mergeStyles = _styles.mergeStyles;
Select.defaultTheme = _theme.defaultTheme;
var _default = Select;
exports.default = _default;
@maris.orbidans see the import translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages. I'm guessing the JS example is
import Select from "react-select";
then it would be (:require ["react-select$default" :as Select])
see the docs. :as
is just a namespace alias after that. so Select/Creatable
works or :refer (Creatable)
also works
ReferenceError: define is not defined
at shadow$provide.module$node_modules$jquery$src$jquery (jquery.js:2:1)
at shadow.js.jsRequire (js.js:66:18)