clojurescript

Fabio Francisco 2025-11-16T11:59:40.399919Z

Hey guys, I am building a personal project, and I have splitted the front and backend into 2 different projects, so in fact, I have 2 different servers, one for the FE and another for the BE. Is there a way to use shadow-cljs to proxy the api requests to my backend server? Or is that the job for a nginx instance instead? Cheers

Fabio Francisco 2025-11-17T09:26:26.763999Z

ok, thanks guys!

Fabio Francisco 2025-11-17T09:26:47.839359Z

and to answer for the reason, yes, it is a requirement

p-himik 2025-11-16T12:07:37.904459Z

Unless it's an ops requirement for some reason, I would absolutely recommend against the split. It's just all-hassle-no-gain. > Is there a way to use shadow-cljs to proxy the api requests to my backend server? Shadow-cljs is a built too. Why would you want to use a build tool for proxying requests?

Roman Liutikov 2025-11-16T12:14:45.544349Z

I guess the reason is a built in server in shadow that serves static assets in dev, handles hot reloading and REPL connection

p-himik 2025-11-16T12:16:46.559599Z

Hot reloading and REPL are unrelated to HTTP requests and don't require anything special, regardless of the setup (that is, unless you develop on a host other than localhost). IMO as soon as one's needs go beyond the most basic dev stuff, the built-in shadow-cljs web server should be replaced with something else.

Roman Liutikov 2025-11-16T12:18:51.748709Z

Here’s related docs section https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support but I’d post the question in #shadow-cljs

thheller 2025-11-16T12:21:41.667409Z

I'd second just using your backend server to serve the output .js files. they are just static files and the server doesn't need to do anything special.

thheller 2025-11-16T12:22:53.189249Z

https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy is actually the correct link @roman01la :devtools-url is something else

gunnar 2025-11-16T14:14:41.183589Z

Not sure if this still holds, but at least this is how I proxied every requests that started with /api to the backend server in a project of mine a few years back:

;; shadow-cljs.edn
 :dev-http {8000 {:proxy-url ""
                  :proxy-predicate foo.client.dev-support/proxy-predicate
                  ,,,}}

;; dev_support.clj
(ns foo.client.dev-support
  (:require [clojure.string :as string]))

(defn proxy-predicate [ex config]
  (string/starts-with? (.getRequestPath ex) "/api"))

thheller 2025-11-16T14:16:28.366479Z

sure that still works. Just seems easier to just have localhost:9000 serve the .js files 🤷