Commit 0d4cf33
fix: normalise Expert inbound origins to bare origin (#7783)
## Description
Fixes #7782.
The Expert panel dropped every inbound `postMessage` sent by the nr-assistant editor plugin on instances that run the editor under a non-root `httpAdminRoot`, logging `Received message from unknown origin. Ignoring.` on repeat. With the messages rejected, the Expert never received `assistant-ready` and the panel did not populate.
`allowedInboundOrigins` compared the incoming `MessageEvent.origin` against `instance.url` / `device.editor.url` directly. Those are full editor URLs that can carry the editor path (`httpAdminRoot`) or a trailing slash, but a `MessageEvent` origin is always a bare `scheme://host:port`, so the strict `includes()` check never matched.
Example (instance with `httpAdminRoot: '/admin'`):
- allow-list entry: `https://my-instance.flowfuse.cloud/admin`
- `event.origin`: `https://my-instance.flowfuse.cloud`
This normalises each allow-list entry to its origin via `new URL(url).origin` before comparison. Instances served at the bare origin are unchanged.
## Testing
`test/unit/frontend/stores/product-assistant.spec.js` gains two regression cases: an `instance.url` carrying an editor path and one with a trailing slash both resolve to the bare origin. Full suite passes (89 tests).
Co-authored-by: andypalmi <andrea@flowfuse.com>1 parent fe7148b commit 0d4cf33
2 files changed
Lines changed: 32 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
303 | 315 | | |
304 | | - | |
305 | | - | |
306 | | - | |
| 316 | + | |
307 | 317 | | |
308 | | - | |
| 318 | + | |
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
236 | 252 | | |
237 | 253 | | |
238 | 254 | | |
| |||
0 commit comments