Conversation
dcalhoun
added this pull request to stack #726
September 23, 2026 19:10
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/725")Built from 8f89e48 |
dcalhoun
force-pushed
the
fix/site-api-root-trailing-slash
branch
from
September 23, 2026 19:38
4ecabd0 to
7904423
Compare
dcalhoun
force-pushed
the
fix/site-api-root-trailing-slash
branch
from
September 23, 2026 20:18
7904423 to
a5c3c94
Compare
dcalhoun
marked this pull request as ready for review
September 24, 2026 10:59
The root is concatenated with the request path, so a root configured without a trailing slash runs into the path and every request 404s: `https://example.com/wp-jsonwp/v2/posts`. Both forms are supported input, and the native URL builders already normalize either one. Reachable when the root comes from REST discovery's last-resort `/wp-json` fallback, which is built without a trailing slash and stored verbatim by the host apps. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014V7YC1kW6f5ZFHtMNGcLKs
dcalhoun
force-pushed
the
fix/site-api-root-trailing-slash
branch
from
September 24, 2026 10:59
a5c3c94 to
8f89e48
Compare
adalpari
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Ensure trailing slash on site API root configuration.
Why?
Mitigate unexpected failures from improper concatenation.
How?
Apply
ensureTrailingSlashbefore configuringapi-fetch's root URL.Testing Instructions
N/A, not addressing known bug, merely increasing robustness.
Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
N/A, no user-facing changes.
AI-generated details
On a site whose API root is configured without a trailing slash, every REST request the editor issues from JavaScript is malformed and 404s, so the editor cannot load its settings or the post. Native-issued requests keep working, because
WordPressRESTURL(iOS) andRestUrlBuilder(Android) both normalize the root, each with a test pinning the unslashed case. The result is a site where the host app works and the web editor does not.The cause is that
createRootURLMiddlewarestrips the path's leading slash and concatenates, so the root has to supply the separator:This is the same class of defect as #595, one level up: there the namespace ran into the following segment, here the root runs into the path.
No in-repo host emits an unslashed root today — the WP.com constant and both self-hosted fallback literals carry the slash. It is reachable because REST discovery's last-resort fallback builds the root by appending a
wp-jsonpath segment, which produces no trailing slash, and the host apps store the discovered value verbatim (blog.restApiRootURLon iOS,site.wpApiRestUrlon Android). That fallback runs when theLinkheader, the<link>tag, and RSD all fail but/wp-jsonresponds — for example on sites whose security plugin strips the header.configureApiFetchnow appliesensureTrailingSlashonce, where the root enters. An unset root stays empty rather than becoming/, which would otherwise resolve every request against the page itself.Android's live editor-assets endpoint already normalizes the root (
stores/EditorAssetsLibrary.kt), and iOS builds it withappending(path:), so no native change is needed.Testing
src/utils/api-fetch.js, replace theensureTrailingSlash( siteApiRoot )argument inconfigureApiFetchwithsiteApiRoot, then: