Skip to content

fix(reflection): use dynamic backend URL instead of hardcoded IP#5954

Open
Rohit-rk07 wants to merge 2 commits intosugarlabs:masterfrom
Rohit-rk07:fix/reflection-backend-url-5918-clean
Open

fix(reflection): use dynamic backend URL instead of hardcoded IP#5954
Rohit-rk07 wants to merge 2 commits intosugarlabs:masterfrom
Rohit-rk07:fix/reflection-backend-url-5918-clean

Conversation

@Rohit-rk07
Copy link
Contributor

Fixes #5918

Summary

This PR removes the hardcoded backend IP in the Reflection widget and replaces it with dynamic backend URL resolution based on window.location, aligned with the existing AI Debugger behavior.

Changes

  • Updated Reflection backend base URL initialization in js/widgets/reflection.js.
  • Added host-aware resolver logic:
    • localhost / 127.0.0.1 -> http://localhost:8000
    • musicblocks.sugarlabs.org -> ${protocol}//api.musicblocks.sugarlabs.org
    • other hosts -> ${protocol}//${hostname}:8000
  • Updated reflection widget tests in js/widgets/__tests__/reflection.test.js to validate dynamic URL behavior.

Validation

  • Ran targeted test:
    • npm test -- js/widgets/__tests__/reflection.test.js --runInBand
  • Result:
    • reflection test suite passed.

Replace hardcoded reflection backend host with hostname-aware resolution aligned with AI debugger behavior.

Add unit tests for local, production, and generic host URL resolution.

Fixes sugarlabs#5918.
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@moksha-hub
Copy link
Contributor

@Rohit-rk07 i had already opened a pr and this issue was also opened by me. can you close your pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] reflection.js uses hardcoded IP address instead of dynamic backend URL like aidebugger.js

2 participants