pedestal

hlship 2025-02-06T01:11:58.802629Z

If you want to produce good documentation, you have to really love it. Documentation is constant work to improve, prune, correct, and keep up to date. Antora makes it easier, but still.

4
❤️ 2
ghaskins 2025-02-06T23:23:00.901309Z

Are there any prescribed ways for using pedestal as the backend of a single-page app? Details in 🧵

ghaskins 2025-02-06T23:24:06.634259Z

What I need is a mix of a) an api route (in this case, /graphql to lacinia), b) some static assets served out of resources (.css/js/html), and for anything else, return index.html

ghaskins 2025-02-06T23:25:20.370669Z

im playing around with catch all parameters and prefix-tree routing, but its not quite working

ghaskins 2025-02-06T23:33:37.372389Z

actually, maybe I can use the not-found interceptor

ghaskins 2025-02-06T23:43:03.687569Z

no, that doesnt quite work either

ghaskins 2025-02-06T23:44:09.930009Z

The problem is that anything I try with catchall or not-found interceptors end up being too greedy, and the route-table is not being consulted for hits first

ghaskins 2025-02-07T00:14:01.686229Z

nm, I think the not-found handler does indeed solve the problem, I just was using it wrong

simongray 2025-02-07T05:56:30.295559Z

The easiest solution is probably a catch-all/wildcard route with a prefix, e.g. /app/* but then you need to accept that all of your public routes have this prefix. If you do SSR then you can do a catch-all route in the frontend instead and then fetch whatever route was requested from the backend as a fixed route. I did this in another project. In my current project I keep both frontend and backend routes in a CLJC file. They go directly into the reitit frontend and are reused (with minor modifications) in the Pedestal backend.

ghaskins 2025-02-07T12:28:18.406509Z

Thanks for the detailed reply. I was able to solve it with a custom not-found-interceptor. For our case, we don’t do SSR but have a kee-frame based SPA that is loaded from a minimal index.html. But if the user navigated to a kee-frame route (say, /foo/bar) and then refreshes the browser, the backend would see GET /foo/bar. Before it was mishandling this, but with the not-found interceptor always serving the SPA if not otherwise handled by pedestal, it rehydrates the kee-frame route correctly