diff --git a/apps/android/app/src/main/java/ai/openclaw/android/gateway/GatewaySession.kt b/apps/android/app/src/main/java/ai/openclaw/android/gateway/GatewaySession.kt index 0c6d14721e0..0ec3132336f 100644 --- a/apps/android/app/src/main/java/ai/openclaw/android/gateway/GatewaySession.kt +++ b/apps/android/app/src/main/java/ai/openclaw/android/gateway/GatewaySession.kt @@ -200,9 +200,7 @@ class GatewaySession( suspend fun connect() { val scheme = if (tls != null) "wss" else "ws" val url = "$scheme://${endpoint.host}:${endpoint.port}" - val httpScheme = if (tls != null) "https" else "http" - val origin = "$httpScheme://${endpoint.host}:${endpoint.port}" - val request = Request.Builder().url(url).header("Origin", origin).build() + val request = Request.Builder().url(url).build() socket = client.newWebSocket(request, Listener()) try { connectDeferred.await() diff --git a/apps/android/app/src/test/java/ai/openclaw/android/gateway/GatewaySessionInvokeTest.kt b/apps/android/app/src/test/java/ai/openclaw/android/gateway/GatewaySessionInvokeTest.kt index a04bcb1606f..e5f98a0b653 100644 --- a/apps/android/app/src/test/java/ai/openclaw/android/gateway/GatewaySessionInvokeTest.kt +++ b/apps/android/app/src/test/java/ai/openclaw/android/gateway/GatewaySessionInvokeTest.kt @@ -19,6 +19,7 @@ import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer import okhttp3.mockwebserver.RecordedRequest import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -35,12 +36,14 @@ class GatewaySessionInvokeTest { val connected = CompletableDeferred() val invokeRequest = CompletableDeferred() val invokeResultParams = CompletableDeferred() + val handshakeOrigin = AtomicReference(null) val lastDisconnect = AtomicReference("") val server = MockWebServer().apply { dispatcher = object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse { + handshakeOrigin.compareAndSet(null, request.getHeader("Origin")) return MockResponse().withWebSocketUpgrade( object : WebSocketListener() { override fun onOpen(webSocket: WebSocket, response: Response) { @@ -148,6 +151,7 @@ class GatewaySessionInvokeTest { assertEquals("node-1", req.nodeId) assertEquals("debug.ping", req.command) assertEquals("""{"ping":"pong"}""", req.paramsJson) + assertNull(handshakeOrigin.get()) assertEquals("invoke-1", resultParams["id"]?.jsonPrimitive?.content) assertEquals("node-1", resultParams["nodeId"]?.jsonPrimitive?.content) assertEquals(true, resultParams["ok"]?.jsonPrimitive?.content?.toBooleanStrict())