I trying out my first project using figwheel + a small jetty based rest API. Developing in emacs. I’m a little confused about what the “normal” development pattern is for jacking in and testing in my browser. The backend and frontend work-sort of, but things aren’t quite right. At the moment I’m loading up my frontend code and doing a jack-in-clj&cljs. That “kinda works” - it starts what appears to be a frontend only server opens a browser window to port 4000. Port 4000 is actually what I have setup as the backend though. So I have to change the URL to 9500, which is actually where figwheel is running. But then I also have to open up my backend code and eval that also to get the backend to start. I’m not sure what the most common pattern here is that I should be using? I want to have the figwheel “goodness” while I’m iterating, but I need my front-end to by able to call my backend, which is listening on a different port and I’d like to be able to automagically start the whole thing without several manual steps?
### A couple of side notes: Once I’m out of dev, I want the whole thing (api + front-end code) served from the same host on port 443. Right now, my backend also successfully serves my packaged front-end, but if I just use that I lose the figwheel hot-reloading during dev).
OK so if I'm hearing you correctly you have a separate server serviing your application. Which should work great with fighweel. The figwheel server can and should run on its own as a side channel. It's only job is to notify the web-client that files have changed. So you can load your application from your separate server and your applications front end will connect with figwheel as long as your application was compiled with figwheel. So figwheel watches your files and then sends notifications through the websocket or http-longpolling. Now I do have to add the caveat that the the mindshare of cljs devs are now using shadow.... And a lot of energy and attention has gone into it. I'm happy to have you use figwheel but I'd be remiss not to mention that. I still like figwheel better but a lot more use cases are covered in shadow I'd imagine
OK - thank you that helps. Yes - you’ve understood my situation. So if my backend is running on port 4000 and my frontend is running on port 9500 should are you saying I should be using my port 4000 (backend) connection in my browser? This does work, as my backend also serves my compiled frontend. However when I make changes to my front-end code in emacs my browser (connected to my backend) doesn’t seem to reload them?
My thought is that because my backend is essentially serving my fully packaged frontend code, that’s why the hot-reloading signaling isn’t working?
Or - if I misunderstood you, maybe I should be browsing to my frontend being served directly by figwheel (on port 9500). That also works, but when I do that I get CORs error when it tries to call the backend on port 4000.
ok so you want your backend to serve the unpacked compiled cljs along when you are developing and to serve packaged assets when you are releasing