WebFaction
Community site: login faq

I am having a weird problem: I am running a node app (node and express.js) which is working fine. However, when I am getting a 404 it just shows the generic 404, not found error, instead of my custom page.

My custom page has been set up like this in the app.js:

app.use(function(req, res) {
    res.status('404').render('404');
}).use(function(err, req, res, next){ 
    res.status('500').render('500');
});

And it is absolutely working fine on my localhost. Any ideas what is going one?

Thanks.

asked 15 Dec '14, 11:23

pilotinspektor
113
accept rate: 0%

edited 15 Dec '14, 18:50

seanf
12.2k41836


I just tested your Node app with a random URL and it served your customized 404 page, so I'm assuming you've fixed this. If you're still seeing the generic page on your end, then feel free to open a support ticket and we'll look into it further.

permanent link

answered 15 Dec '14, 20:08

seanf
12.2k41836
accept rate: 37%

Hi Sean,

many thanks for looking into it. Am still encountering the problem, but since you are getting the custom page now I am thinking maybe the problem is due to the proxy server I have set up in order to be able to serve a custom 502, as described here:

https://community.webfaction.com/questions/12557/custom-502-page

Happy to create a support ticket, but maybe it is worth trying to sort it out here as I imagine other people might run into the same issue?

(15 Dec '14, 20:13) pilotinspektor

Try adding a 404 handler to your proxy's .htaccess, something like:

ErrorDocument 404 /404.html
ErrorDocument 502 /down.html
ErrorDocument 503 /down.html

RewriteEngine on
RewriteBase /
RewriteCond   %{REQUEST_URI}  !^/(down|404)\.html
RewriteRule ^(.*)$ http://127.0.0.1:12345/$1 [P,L]

Then put 404.html in your proxy's webpapp directory.

(15 Dec '14, 20:23) seanf

Yes, that is a possibility. I was just hoping that there is a better solution which would mean that I don't have to build a second version of the site in order to show header, footer, menu and so on on the 404 page.

(15 Dec '14, 21:15) pilotinspektor
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×67
×22

question asked: 15 Dec '14, 11:23

question was seen: 1,504 times

last updated: 15 Dec '14, 21:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM