Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The not found handler is returning 200 instead of 404 #137

Open
soapdog opened this issue Oct 11, 2016 · 9 comments
Open

The not found handler is returning 200 instead of 404 #137

soapdog opened this issue Oct 11, 2016 · 9 comments

Comments

@soapdog
Copy link
Contributor

soapdog commented Oct 11, 2016

When returning a 404 from a controller or even from Sailor itself, the status code is 200 and not 404 like it should be.

I believe the problem lies in https://github.com/sailorproject/sailor/blob/master/src/sailor.lua#L148, but I am not sure. A not found page should return 404 status...

@soapdog
Copy link
Contributor Author

soapdog commented Oct 11, 2016

I can work on a PR if that is indeed the correct location...

@felipedaragon
Copy link
Member

@soapdog Which web server are you using?

@soapdog
Copy link
Contributor Author

soapdog commented Oct 11, 2016

@felipedaragon local development with Xavante and deployment to Apache.

@Etiene
Copy link
Member

Etiene commented Oct 11, 2016

duplicate #24

I never succeeded in making xavante do the appropriate code return. I can try again because it's been a while. The problem is specially when the dev wants to have custom 404 pages.

Edit: still not successful

@soapdog
Copy link
Contributor Author

soapdog commented Oct 11, 2016

It is happening on both Xavante and Apache. I will work out a PR.

@Etiene
Copy link
Member

Etiene commented Oct 12, 2016

Oh yea, it should not be the case in apache! Thanks for the PR :)

@aleksmelnikov
Copy link

I am not sure but...
If web server return 404 error then a browser will show it own 404 error page. So, it will not be custom 404 web server error page. If web server return custom 404 error page then it will do with 200ok because it is a normal page for a browser.

Is the framework currently support custom 404 error page? I have tested to go on http://sailorproject.org/help and have got this text:

/var/www/sailor_framework/src/sailor.lua:184: module 'controllers.help' not found:
no field package.preload['controllers.help']
no file '/var/www/sailor/controllers/help.lua'
no file '/usr/local/share/lua/5.1/controllers/help.lua'
no file '/usr/local/share/lua/5.1/controllers/help/init.lua'
no file '/usr/local/lib/lua/5.1/controllers/help.lua'
no file '/usr/local/lib/lua/5.1/controllers/help/init.lua'
no file '/usr/share/lua/5.1/controllers/help.lua'
no file '/usr/share/lua/5.1/controllers/help/init.lua'
no file '/var/www/sailor_framework/src/controllers/help.lua'
no file '/var/www/sailor/controllers/help.so'
no file '/usr/local/lib/lua/5.1/controllers/help.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/controllers/help.so'
no file '/usr/lib/lua/5.1/controllers/help.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/var/www/sailor/controllers.so'
no file '/usr/local/lib/lua/5.1/controllers.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/controllers.so'
no file '/usr/lib/lua/5.1/controllers.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/var/www/sailor_framework/src/sailor.lua:184: in function
[C]: in function 'xpcall'
/var/www/sailor_framework/src/sailor.lua:184: in function
(tail call): ?

Not custom 404 error page.
:(

@d9k
Copy link

d9k commented Jun 20, 2017

If web server return 404 error then a browser will show it own 404 error page

@superriva, try to debug some popular site custom 404 page, for example http://google.com/non-existing-page with Chrome developer tools, Network tab and you'll see Status Code: 404
google 404

@soapdog
Copy link
Contributor Author

soapdog commented Jun 20, 2017

Exactly @d9k. Status codes should be respected. You can have a custom 404 and return the correct code. I forgot to do this PR, argh. Will fix.

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

No branches or pull requests

5 participants