From 737eac699e996db7b91c60c9f3990cfb09d2e083 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Feb 2026 12:20:35 -0500 Subject: [PATCH 1/2] fix: Use dev server origin for CORS headers when configured 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. --- .../main/java/org/wordpress/gutenberg/GutenbergView.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt b/android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt index aab3c676..e1684d46 100644 --- a/android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt +++ b/android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergView.kt @@ -607,7 +607,13 @@ class GutenbergView : FrameLayout { } private fun addCorsHeaders(headers: MutableMap) { - headers["Access-Control-Allow-Origin"] = "https://appassets.androidplatform.net" + val origin = if (BuildConfig.GUTENBERG_EDITOR_URL.isNotEmpty()) { + val uri = Uri.parse(BuildConfig.GUTENBERG_EDITOR_URL) + "${uri.scheme}://${uri.host}${if (uri.port != -1) ":${uri.port}" else ""}" + } else { + "https://appassets.androidplatform.net" + } + headers["Access-Control-Allow-Origin"] = origin headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD" headers["Access-Control-Allow-Headers"] = "Authorization, Content-Type, Accept, X-WP-Nonce" headers["Access-Control-Allow-Credentials"] = "true" From f05e0098f7f18ddb357731b11f9c32e8365b0929 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Feb 2026 12:26:08 -0500 Subject: [PATCH 2/2] fix: Ensure post id is truthy so editor becomes ready `__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. --- src/utils/bridge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/bridge.js b/src/utils/bridge.js index fd2acf3b..b9e0caae 100644 --- a/src/utils/bridge.js +++ b/src/utils/bridge.js @@ -299,7 +299,7 @@ export async function getPost() { if ( hostContent ) { debug( 'Using content from native host' ); return { - id: post?.id ?? -1, + id: post?.id || -1, type: post?.type || 'post', status: post?.status || 'draft', title: { raw: hostContent.title }, @@ -310,7 +310,7 @@ export async function getPost() { if ( post ) { debug( 'Native bridge unavailable, using GBKit initial content' ); return { - id: post.id, + id: post.id || -1, type: post.type || 'post', status: post.status || 'draft', title: { raw: decodeURIComponent( post.title ) },