Skip to content

Commit

Permalink
Merge branch 'main' into fix/formatting-test
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem authored Jun 30, 2024
2 parents 7df69b5 + 731299e commit 19bb7f5
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion gateway/dist/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script id="env-config" type="application/json">
%ENV_CONFIG%
</script>
<script defer src="/runtime.8441d271053c46f9400c.bundle.js"></script><script defer src="/main.9f929cc4df2c98a03137.bundle.js"></script></head>
<script defer src="/runtime.8441d271053c46f9400c.bundle.js"></script><script defer src="/main.9a8feb49fef53c955bcf.bundle.js"></script></head>

<body>
<noscript style="white-space: pre; font-family: monospace">
Expand Down
2 changes: 1 addition & 1 deletion gateway/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script id="env-config" type="application/json">
%ENV_CONFIG%
</script>
<script defer src="/runtime.8441d271053c46f9400c.bundle.js"></script><script defer src="/main.9f929cc4df2c98a03137.bundle.js"></script></head>
<script defer src="/runtime.8441d271053c46f9400c.bundle.js"></script><script defer src="/main.9a8feb49fef53c955bcf.bundle.js"></script></head>

<body>
<noscript style="white-space: pre; font-family: monospace">
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gateway/src/useAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { flags } from "../config/flags.js";

export const refreshAllowanceObj = {};
const NetworkId = flags.network;
const RPC_URL = "http://127.0.0.1:8080/" + "api/proxy-rpc";
const RPC_URL = `${window.location.origin}/api/proxy-rpc`;

export function useAuth() {
const [connected, setConnected] = useState(false);
Expand Down
4 changes: 2 additions & 2 deletions gateway/src/useRedirectMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function useRedirectMap() {

useEffect(() => {
if (uWebSocket) {
const socket = io(flags.bosLoaderWs, {
const socket = io(`ws://${window.location.host}`, {
reconnectionAttempts: 1, // Limit reconnection attempts
});

Expand All @@ -21,7 +21,7 @@ function useRedirectMap() {
});

socket.on("connect_error", () => {
console.warning("WebSocket connection error. Switching to HTTP.");
console.warn("WebSocket connection error. Disabling WebSocket");
setUWebSocket(false);
socket.disconnect();
});
Expand Down
12 changes: 0 additions & 12 deletions lib/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ function htmlStringify(json) {

export const handleReplacements = (html: string, opts: DevOptions): string => {
const envConfig = JSON.stringify({
bosLoaderWs: `ws://127.0.0.1:${opts.port}`,
bosLoaderUrl: `http://127.0.0.1:${opts.port}/api/loader`,
enableHotReload: opts.hot,
network: opts.network,
});
Expand All @@ -29,16 +27,6 @@ export const handleReplacements = (html: string, opts: DevOptions): string => {
pattern: "%ENV_CONFIG%",
replacement: envConfig
},
OTHER: {
pattern: /<near-social-viewer><\/near-social-viewer>/g,
replacement: true
? `<near-social-viewer
${renderAttribute("src", opts.index)}
${renderAttribute("rpc", `http://127.0.0.1:${opts.port}/api/proxy-rpc`)}
${renderAttribute("network", opts.network)}
></near-social-viewer>`
: "<near-social-viewer></near-social-viewer>",
}
}));
}

Expand Down
5 changes: 4 additions & 1 deletion lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ export function createApp(devJsonPath: string, opts: DevOptions): Express.Applic
app.get("*", (_, res) => {
readFile(path.join(gatewayPath, "index.html"), "utf8")
.then(data => {
const modifiedDist = modifyIndexHtml(data, opts);
let modifiedDist = modifyIndexHtml(data, opts);
if (gatewayPath === GATEWAY_PATH) {
modifiedDist = handleReplacements(modifiedDist, opts);
}
res.type('text/html').send(modifiedDist);
})
.catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bos-workspace",
"version": "1.0.0-alpha.29",
"version": "1.0.0-alpha.30",
"description": "",
"bin": {
"bos-workspace": "./bin/bw.js",
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ describe("gateway", () => {
it("should replace the ENV_CONFIG placeholder with correct JSON configuration", () => {
const htmlInput = "<html><head>%ENV_CONFIG%</head><body></body></html>";
const expectedConfig = JSON.stringify({
bosLoaderWs: `ws://127.0.0.1:8080`,
bosLoaderUrl: `http://127.0.0.1:8080/api/loader`,
enableHotReload: mockOpts.hot,
network: mockOpts.network,
});
Expand Down

0 comments on commit 19bb7f5

Please sign in to comment.