mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-08-29 18:31:33 +00:00
fix: keep localhost database export same-origin (#1112)
This commit is contained in:
@@ -20,10 +20,7 @@ export function getDatabaseTransferUrl(
|
|||||||
return `${serverUrl.replace(/\/$/, "")}/database/${operation}`;
|
return `${serverUrl.replace(/\/$/, "")}/database/${operation}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const development =
|
const development = location.port === "5173";
|
||||||
location.port === "5173" ||
|
|
||||||
location.hostname === "localhost" ||
|
|
||||||
location.hostname === "127.0.0.1";
|
|
||||||
|
|
||||||
if (development) {
|
if (development) {
|
||||||
return `http://localhost:30001/database/${operation}`;
|
return `http://localhost:30001/database/${operation}`;
|
||||||
|
|||||||
@@ -51,4 +51,21 @@ describe("getDatabaseTransferUrl", () => {
|
|||||||
}),
|
}),
|
||||||
).toBe("http://localhost:30001/database/export");
|
).toBe("http://localhost:30001/database/export");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each(["localhost", "127.0.0.1"])(
|
||||||
|
"keeps Docker access through %s on the browser origin",
|
||||||
|
(hostname) => {
|
||||||
|
expect(
|
||||||
|
getDatabaseTransferUrl("export", {
|
||||||
|
electron: false,
|
||||||
|
location: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: `${hostname}:8080`,
|
||||||
|
hostname,
|
||||||
|
port: "8080",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).toBe(`http://${hostname}:8080/database/export`);
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user