node-ecstatic icon indicating copy to clipboard operation
node-ecstatic copied to clipboard

Use 200.html as a fallback before 404.html

Open geelen opened this issue 7 years ago • 7 comments

This is a convention I think makes a lot of sense for single page applications, when a URL doesn't match anything.

  • First check for /200.html and serve that with status 404
  • Then check for /404.html and serve that with status 404
  • Then serve a blank 404

This was introduced by harp (I think) and is used by surge.sh and it seems to be really straightforward to use.

I've made it so that if you set the config of handleError to false then this doesn't look for 200.html either, just to keep compatibility with other clients.

geelen avatar Sep 06 '16 05:09 geelen

Hey, just now seeing this. Will try to review in the next few days.

jfhbrook avatar Sep 22 '16 01:09 jfhbrook

So, uh, yeah! Github's new review feature is okay.

jfhbrook avatar Sep 22 '16 01:09 jfhbrook

Last thought: Is this testable?

jfhbrook avatar Sep 22 '16 02:09 jfhbrook

I lied:

Do you think this PR solves a similar problem as https://github.com/jfhbrook/node-ecstatic/pull/146 ?

jfhbrook avatar Sep 22 '16 03:09 jfhbrook

@jfhbrook it solves similar problem for me in a less flexible way.

In my case, I'd love to be able to give custom fallback page, and not rely on convention 200/404.html pages

slorber avatar Nov 10 '16 17:11 slorber

I wouldn't have expected any special 200/404 file behaviour either, as the README doesn't mention it.

mk-pmb avatar Oct 18 '17 14:10 mk-pmb

Feel free to PR some clarifying docs @mk-pmb

jfhbrook avatar Oct 18 '17 15:10 jfhbrook