Skip to content

fix: detect REST context when using plain-permalink ?rest_route= routing#6

Open
superdav42 wants to merge 2 commits intox-wp:masterfrom
superdav42:fix/rest-context-plain-permalink-support
Open

fix: detect REST context when using plain-permalink ?rest_route= routing#6
superdav42 wants to merge 2 commits intox-wp:masterfrom
superdav42:fix/rest-context-plain-permalink-support

Conversation

@superdav42
Copy link
Copy Markdown

WordPress routes REST API requests via ?rest_route=/... when pretty permalinks are disabled (e.g. fresh wp-env installs, many CI environments).

XWP_Context::rest() only checked REQUEST_URI for the /wp-json/ prefix, so plain-permalink REST requests were never detected as REST context. This caused all DI handlers with context: CTX_REST to be skipped, returning 404 for every REST endpoint.

Add a secondary check for the rest_route query var to cover this path.

WordPress routes REST API requests via `?rest_route=/...` when pretty
permalinks are disabled (e.g. fresh wp-env installs, many CI environments).

`XWP_Context::rest()` only checked REQUEST_URI for the /wp-json/ prefix,
so plain-permalink REST requests were never detected as REST context.
This caused all DI handlers with `context: CTX_REST` to be skipped,
returning 404 for every REST endpoint.

Add a secondary check for the `rest_route` query var to cover this path.
Refactor rest() method to use xwp_fetch_get_var for retrieving rest_route.
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

Successfully merging this pull request may close these issues.

1 participant