reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
395 stars 55 forks source link

Prone does not work out of the box #157

Closed miikka closed 5 years ago

miikka commented 5 years ago

Whenever I have exceptions, I'm getting an empty page in the browser and 404 errors in the browser console about prone.js, prone-lib.js, and prone.css.

Steps to reproduce:

  1. Create a new project with lein new reagent foo
  2. Edit src/clj/foo/handler.clj and add (throw (Exception. "hello")) to the body of index-handler.
  3. Start the server with lein figwheel.
  4. Open http://localhost:3449 with a browser

What happens: Browser shows a blank page and there are 404 errors in the console. What I expected: Browsers shows a page full of information about the exception.

yogthos commented 5 years ago

This template requires you to start the server using lein run and it will be available on port 3000 by default. Figwheel is only used for compiling ClojureScript, and the server it runs should not be used.

Note that if you want to make a front-end only project you can use the reagent frontend template by running lein new reagent-frontend foo. That project will be setup to be accessible via Figwheel server.

miikka commented 5 years ago

Okay, but the same problem happens if I start the server with lein run and go to http://localhost:3000/. Thus I suggest re-opening.

Also, if the Figwheel server should not ever be used, maybe that should be mentioned in the README of the generated template. Now it only says that you might want to not use if you're using websockets or doing something special otherwise.

yogthos commented 5 years ago

You're right, I just tested locally and can see the behavior as well. It looks like using {:data {:middleware middleware}} doesn't load the resources, when I switch to wrap the entire reitit-ring/ring-handler with the middleware prone works as expected.

I'll update the template and add a note in the readme regarding using Figwheel.

yogthos commented 5 years ago

Just pushed out a new version with a fix. I also took a second look at Figwheel, and it should actually be safe to use because the handler is explicitly declared in the config in project.clj as :ring-handler {{project-ns}}.handler/app. So, Figwheel will use the same handler as the Ring server started by lein run.

miikka commented 5 years ago

Now it works! Thanks.