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" 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 ) },