Fork me on GitHub
Daniel Hines00:06:36

Hey guys. I’m trying running one http server on my Mac on port 8700. On a Windows VM, another http server is running on 3375. In my browser in Windows, when I hit my IP on 8700, everything works great. However, when I add main.js as a script on one of the pages running on 3375 in Windows, when it loads, I’m getting the following errors:

Daniel Hines01:06:58

If you look at the screenshot, it's asking for the goog scripts on localhost, but they aren't hosted there - it's on a different url and port


IUC, this looks like a job for the proxy. It'll search for files locally and forward to the proxy when not found

Daniel Hines01:06:30

Is there like a one liner cli tool you know of to do that?

Daniel Hines01:06:22

Scratch that - I see your post below

👍 4
Daniel Hines00:06:41

The problem is obvious - those files aren’t hosted on that port. Any suggestions on a solution? Some config in Shadow, perhaps?

Daniel Hines01:06:12

If theres no easy fix on the shadow-cljs side, I can probably work things from the other direction.

Daniel Hines01:06:38

So if my shadow-cljs http server is hosting my code at http://my-ip:8700, I set :devtools-url to that?


> shadow-cljs will then use the :devtools-url as the base when making requests. It is not the final URL so you must ensure that all requests starting with the path you configured (eg. /shadow-cljs/*) are forwarded to the host shadow-cljs is running on.

Daniel Hines01:06:09

Oh, this must be the prxy you mentioned in the thread


@d4hines the default logic of shadow-cljs will try to load the JS from the current document location. so if you access the initial HTML via it'll attempt to load the files from 8700


you can override that behavior via :devtools-url or the proxy config as pointed out above


another thing that also works is just setting a full host in the :asset-path config option. so :asset-path ""

Daniel Hines12:06:05

Ah! This helped a bunch! I’m so close now. The only remaining error is this one:

Daniel Hines12:06:10

browser.cljs:343 WebSocket connection to ‘<ws://localhost:9630/ws/worker/app/60bb278c-7f0a-4cfc-9db2-5b4aec3572e5/2ddbda70-5ea9-4725-a1c2-1aa32811f7e4/browser>’ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Daniel Hines12:06:04

For this, it looks like, according to 4.4.4 in guide, I need to set something like:

:http {:port 9630 :host "my-ip"}

Daniel Hines12:06:30

I added that config, and I get the following output in the console:

shadow-cljs - server version: 2.8.39 running at 

Daniel Hines12:06:50

However, I still get the above error, where it’s looking for websockets on localhost.


this is the same underlying issue


for this you'll need to set :devtools-url properly

Daniel Hines12:06:02

I was just about to post that I did exactly that and it’s working!

Daniel Hines12:06:10

Thanks a ton for your help!


The "build report" feature is not working for me: I run shadow-cljs run <my-build-id> report.html and it raises an error: NoSuchFileException: .shadow-cljs/release-snapshots/dev/latest/main.js


Do I need to do some step before I run build-report?


@mauricio.szabo build reports currently only work with :browser builds? do you use :browser?


No, I'm using node_script. Sorry, I think I've missed this information on the documentation.


don't think it mentions that


in theory it could work for node-script but haven't done the work to make it work


seems less important anyhow given that size is not really a concern for node-script builds


Also, how do I contribute to the documentation? On the "editor integration" part I could add Chlorine, socket REPL package for Atom, as it currently supports shadow-cljs out of the box 🙂