You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "nanamikon (via GitHub)" <gi...@apache.org> on 2024/04/26 07:44:18 UTC
Re: [I] help request: handle nginx error_pages directives [apisix]
nanamikon commented on issue #8628:
URL: https://github.com/apache/apisix/issues/8628#issuecomment-2078818222
error_page may not work if we use ngx.print or ngx.say, see https://github.com/openresty/lua-nginx-module/issues/1541
For example, when route not found , core.response.exit with message will call ngx.print, in this case, error_page will not work.
```
----- /apisix/init.lua
local route = api_ctx.matched_route
if not route then
-- run global rule when there is no matching route
local global_rules = apisix_global_rules.global_rules()
plugin.run_global_rules(api_ctx, global_rules, nil)
core.log.info("not find any matched route")
return core.response.exit(404,
{error_msg = "404 Route Not Found"})
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org