fix: Resolve dev server CORS errors and falsy post id blocking editor render#317
Merged
jkmassel merged 2 commits intointegrate/wp-androidfrom Feb 10, 2026
Merged
Conversation
The CORS proxy in `addCorsHeaders` was hardcoded to `https://appassets.androidplatform.net`, which is correct for bundled assets but causes CORS failures when using a local dev server via `GUTENBERG_EDITOR_URL`. The browser rejects the proxied responses because `Access-Control-Allow-Origin` doesn't match the dev server origin. Derive the origin from `GUTENBERG_EDITOR_URL` when it's set, falling back to the bundled asset origin otherwise.
`__unstableIsEditorReady()` returns `!!state.postId`, so a post id of `0` keeps the editor permanently in a "not ready" state. Use `||` instead of `??` to fall back to `-1` for all falsy ids (not just null/undefined), matching the existing fallback path.
jkmassel
approved these changes
Feb 10, 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?
Two fixes that resolve the Android editor failing to render when using a local dev server via
GUTENBERG_EDITOR_URL.Why?
After the native CORS proxy was added in cad54a1, using a local dev server (
GUTENBERG_EDITOR_URL) caused two issues:Access-Control-Allow-Originheader was hardcoded tohttps://appassets.androidplatform.net, which doesn't match the dev server origin (e.g.,http://192.168.0.114:5173). The browser rejected all proxied API responses.__unstableIsEditorReady()returns!!state.postId, so a post id of0(falsy) keeps the editor permanently stuck returningnull. The host app was providingid: 0, which passed through unchecked.How?
GutenbergView.kt):addCorsHeadersnow derives the origin fromBuildConfig.GUTENBERG_EDITOR_URLwhen set, falling back to the bundled asset origin otherwise.bridge.js): Changed??to||for post id fallback ingetPost(), so all falsy ids (including0) fall back to-1, consistent with the existing default path.Testing Instructions
GUTENBERG_EDITOR_URL=http://<your-ip>:5173/inandroid/local.propertiesmake dev-serverAccessibility Testing Instructions
No UI changes.