baiuu opened a new issue, #13739:
URL: https://github.com/apache/apisix/issues/13739
### Description
### Body
Currently, the `body` configured in the `error-page` plugin metadata is
returned to clients as a static string. In practice, operators often want to
embed request-scoped information into custom error pages — most commonly the
**request ID**, so that end users can report it and administrators can
correlate the error page with access/error logs.
### Proposal
Resolve Nginx variables (via `core.utils.resolve_var`, the same mechanism
used by `response-rewrite` headers) in the error page `body` before sending the
response:
```json
{
"enable": true,
"error_404": {
"body": "<html><body><h1>404 Not Found</h1><p>Request ID:
$request_id</p></body></html>"
}
}
```
- Variables are resolved in `header_filter` so that `Content-Length` is
computed from the **final rendered body** (avoids truncation/stalling).
- Supports `$var`, `${var}`, the `??` default-value operator, and `\$`
escaping — identical semantics to `response-rewrite` header values.
- No schema changes; fully backward compatible (bodies without `$` are
returned unchanged, short-circuited before regex processing).
### Use cases
- `$request_id` — request tracing / log correlation (the primary motivation)
- `$remote_addr`, `$host`, `$uri`, `$time_iso8601` — richer diagnostic error
pages
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]