Fork me on GitHub
#re-frame
<
2015-08-12
>
pupeno09:08:21

I am using client-side routing. What’s the appropriate way of issuing a 404?

timgilbert14:08:00

@pupeno, we’re using something like this as our very last route to catch fall-throughs and display a 404 page, is that what you mean?

(defroute "/:anything-else" [anything-else]
    (re-frame/dispatch [:set-active-panel :not-found])))

pupeno14:08:11

Sometimes the URL matches a route, but it’s still a 404. Nevertheless, that code doesn’t give the browser the 404 error, only displays the error. Correct?

escherize14:08:34

So, I'm using re-frame 0.4.1, with re-com 0.6.0 and seeing:

Compile Error
clojure.lang.ExceptionInfo : failed compiling file:src/cljs/homing_pigeon/views/hub.cljs
clojure.lang.ExceptionInfo : Referred var re-com.util/deep-merge does not exist

escherize14:08:13

and, the string deep-merge does not exist anywhere in my project

timgilbert14:08:08

That’s true pupeno

timgilbert14:08:39

The browser would still get a 200 response code. To change that you need to mess with the web server code (if you have one, for me it’s figwheel locally)

timgilbert14:08:39

Although for us most of the time the browser doesn’t actually make a new request to the server

pupeno14:08:52

timgilbert: the server might not ever receive a request. I’m only interested in javascript/clojurescript generating a 404.

timgilbert14:08:03

Well, the 404 is a status code on an http response

timgilbert14:08:18

So without a server there’s no response

pupeno14:08:51

And a cookie is an http header but javascript can generate new ones. So, just the fact that it’s an http response it’s not in my mind enough to rule it out.

antishok14:08:54

@escherize: tried cleaning the output files, doing a clean build?

timgilbert15:08:47

I guess I’m just not clear on what you would expect to be reading that response

escherize15:08:23

I think a cookie is more than just an http header, but 404 is only a http response code.

pupeno15:08:55

Yeah, apparently it’s impossible to tell the browser that the current URL is a 404 in JS.

escherize15:08:16

Also @antishok that did the trick, Thanks.

escherize15:08:28

I need to get a tatto about lein clen when messing with deps