I have custom plugin for the Kong Gateway v3.6.0 During the access phase it may kong.response.exit with a 500 status. I'm later catching responses with status of 500 during the header_filter phase (which may come from access or from the service responses) and changing them to a 307 redirect to a custom error page.
I get the following error: [error] 37#0: *2378 attempt to set status 500 via ngx.exit after sending out the response status 307
I have tried two different approaches:
using kong.response.exit:
and just modifying the status and header directly:
both of these result in an functioning redirects to the location_url, but they also litter the kong logs with error messages...
Is there a better way?
during the header_filter phase (which may come from access or from the service responses)
header_filter phase is run when all header bytes from the upstream have been received.
I think you cannot call kong.response.exit(...) and on access
context then
expected to run something on header_filter
context on the same request since the request will be cut short before proxying to the upstream.
Also, you response of attempt to set status 500 via ngx.exit after sending out the response status 307
seems like you are ordering the call incorrectly, e.g. calling kong.response.exit
before calling kong.response.set_status
.
What is the main purpose of the plugin? During the access phase it may kong.response.exit with a 500 status
and then catching responses with status of 500 during the header_filter phase
seems counter-intuitive for me.
Could you provide the plugin code?