fix(osis_app): correct RPC URL pattern and context header #39
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_osis!39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_fix_osis_island_rpc_url"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes the OSIS Dioxus island so it can talk to
hero_osis_basefrom inside hero_os (built withFEATURES=web-native). The island previously POSTed to/hero_osis/ui/rpc/{context}, which has no handler on hero_router and failed with"Service unavailable — unexpected response".The new code builds the URL as
{api_host}/hero_osis_<domain>/rpc(domain derived from the JSON-RPC method's first dotted segment) and sends the context via theX-Hero-ContextHTTP header — matching the documented Hero RPC pattern.Related Issue
Closes #37
Changes
crates/hero_osis_app/src/rpc.rsRPC_BASE→API_HOST,set_rpc_base→set_api_host,rpc_base→api_host.{base}/rpc/{context}. New:{api_host}/hero_osis_<domain>/rpc.domain == "rpc"to fall back to"base"sorpc.discoverreacheshero_osis_base/rpcrather than the non-existenthero_osis_rpc.X-Hero-Context: <context>header to every request; the context is no longer placed in the URL path.api_host()yields a same-origin relative URL (e.g./hero_osis_base/rpc) — correct behind hero_router.auth_header()Bearer-token injection fromlocalStorage, the JSON-RPC body shape, and response/error parsing.//!doc comment to describe the new URL pattern, domain derivation rule, and header semantics.crates/hero_osis_app/src/app.rscrate::rpc::set_rpc_base("/hero_osis/ui")withcrate::rpc::set_api_host(&props.context.api_host). All three existingrpc::rpc(...)callsites are unchanged — they already pass the context as the first argument, which the newrpc()puts in the header.Test Results
cargo check --target wasm32-unknown-unknownoncrates/hero_osis_apppasses clean.make test(the CI-style invocation:cargo test --lib --no-default-features --features all-domains) passes: 113/113 inhero_osis_server, 0 tests inhero_osis_sdkandhero_osis_ui.grep -rn "set_rpc_base\|RPC_BASE\|rpc_base" --include="*.rs"returns no matches — no orphan callers of the renamed symbols.hero_oslocally withFEATURES=web-nativeagainst this branch via a local Cargo[patch]. Opening the OSIS island in hero_os now successfully reacheshero_osis_baseand lists contexts. Requests in DevTools → Network showPOST /hero_osis_base/rpcwithX-Hero-Context: root, never/hero_osis/ui/rpc/....Notes
make dev-minimal→http://127.0.0.1:9988/hero_osis/ui/) is unaffected. It uses Askama templates +js/dashboard.jsand does not importhero_osis_app.rpc.discovernow hitshero_osis_baseonly (instead of all installed domains via the previous — broken — service hub call). The "Domains in context" panel will list onlybase.*methods after a context is selected. Functionally this is a strict improvement over the prior "Service unavailable" failure; restoring full domain aggregation by fanning out to every installed OSIS domain can be tracked as a follow-up.The OSIS Dioxus island posted to {base}/rpc/{context} with base hard-coded to /hero_osis/ui, which routes through hero_router to the hero_osis_ui HTML server (which has no /rpc/{context} handler) and fails with "Service unavailable - unexpected response". Switch to the canonical Hero pattern: build the URL from the JSON-RPC method's first dotted segment ({api_host}/hero_osis_<domain>/rpc) and send the execution context via the X-Hero-Context HTTP header. Take the api_host from IslandContext::api_host (already a prop on HeroOsisApp) instead of a hard-coded path. When the method namespace is "rpc" (i.e. rpc.discover), fall back to "base" so the request reaches a real domain service rather than the non-existent hero_osis_rpc. #37