Open soapdog opened 7 years ago
I can work on a PR if that is indeed the correct location...
@soapdog Which web server are you using?
@felipedaragon local development with Xavante and deployment to Apache.
duplicate https://github.com/sailorproject/sailor/issues/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
It is happening on both Xavante and Apache. I will work out a PR.
Oh yea, it should not be the case in apache! Thanks for the PR :)
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. :(
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
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.
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...