Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Figwheel as app server #204

Closed
malfario opened this issue Jun 27, 2017 · 3 comments
Closed

Figwheel as app server #204

malfario opened this issue Jun 27, 2017 · 3 comments

Comments

@malfario
Copy link
Contributor

Hi!

The README generated for my project with Chestnut 0.15.1 states:

Figwheel's server will also act as your app server, so requests are correctly forwarded to the http-handler you define.

However, Compojure routes defined in project.routes/home-routes are not accessible through Figwheel's server at localhost:3449, but through the Jetty instance running on localhost:10555.

Is there a way to expose new routes through Figwheel's HTTP server?

Thanks in advance!

@plexus
Copy link
Owner

plexus commented Jun 27, 2017

Thanks for reporting this, we'll likely change this back because the different ports are confusing people. In the meanwhile this should be removed from the README. I don't have time for it at the moment though but it would be great if someone could submit a PR.

What you can do as a workaround is put this in user.clj

(def figwheel-http-handler
  (constantly {:status 301
               :headers {"Location" "http://localhost:10555"}}))

And in project.clj

  :figwheel {
             ;;;;; snip
             :ring-handler user/figwheel-http-handler
           }

If you really want to also serve up things through Figwheel you can set up a handler that reaches into reloaded.repl/system and finds the current system's handler from there.

(defn figwheel-http-handler  [req]
  ((get-in reloaded.repl/system [:handler :handler]) req))

@malfario
Copy link
Contributor Author

Thank you so much, your last suggestion allows me to write clean cljs-ajax queries while being CORS friendly:

(GET "/tickets") vs (GET "http://localhost:10555/tickets")

Cheers!

@malfario
Copy link
Contributor Author

Closed by 3a5a95c

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants