diff --git a/js/widgets/__tests__/reflection.test.js b/js/widgets/__tests__/reflection.test.js index 2e375b781f..d9fdefe711 100644 --- a/js/widgets/__tests__/reflection.test.js +++ b/js/widgets/__tests__/reflection.test.js @@ -124,7 +124,7 @@ describe("ReflectionMatrix", () => { expect(reflection.isOpen).toBe(true); expect(reflection.isMaximized).toBe(false); expect(mockActivity.isInputON).toBe(true); - expect(reflection.PORT).toBe("http://3.105.177.138:8000"); + expect(reflection.PORT).toBe("http://localhost:8000"); expect(window.widgetWindows.windowFor).toHaveBeenCalledWith( reflection, diff --git a/js/widgets/reflection.js b/js/widgets/reflection.js index 5941359161..6ca9b70ca5 100644 --- a/js/widgets/reflection.js +++ b/js/widgets/reflection.js @@ -76,7 +76,18 @@ class ReflectionMatrix { this.isOpen = true; this.isMaximized = false; this.activity.isInputON = true; - this.PORT = "http://3.105.177.138:8000"; // http://127.0.0.1:8000 + this.PORT = (() => { + if ( + window.location.hostname === "localhost" || + window.location.hostname === "127.0.0.1" + ) { + return "http://localhost:8000"; + } else if (window.location.hostname.includes("musicblocks.sugarlabs.org")) { + return `${window.location.protocol}//api.musicblocks.sugarlabs.org`; + } else { + return `${window.location.protocol}//${window.location.hostname}:8000`; + } + })(); const widgetWindow = window.widgetWindows.windowFor(this, "reflection", "reflection"); this.widgetWindow = widgetWindow;