Skip to content

Commit

Permalink
fix: add hostname check to decide http mode in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Oct 16, 2024
1 parent c3deb33 commit ead2439
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ type Props = {
};

export default function ExternalLink({ to, className, children }: Props) {
const isHttpMode = window.location.protocol.startsWith("http");
const isHttpMode =
window.location.protocol.startsWith("http") &&
!window.location.hostname.startsWith("wails");

return isHttpMode ? (
<Link
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/layouts/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ export default function AppLayout() {
deleteAuthToken();
await refetchInfo();

const isHttpMode = window.location.protocol.startsWith("http");
const isHttpMode =
window.location.protocol.startsWith("http") &&
!window.location.hostname.startsWith("wails");
if (isHttpMode) {
window.location.href = "/logout";
} else {
navigate("/", { replace: true });
}
}, [navigate, refetchInfo]);

const isHttpMode = window.location.protocol.startsWith("http");
const isHttpMode =
window.location.protocol.startsWith("http") &&
!window.location.hostname.startsWith("wails");

if (!info) {
return null;
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/screens/BackupNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function BackupNode() {
const onSubmitPassword = async (e: React.FormEvent) => {
e.preventDefault();

const isHttpMode = window.location.protocol.startsWith("http");
const isHttpMode =
window.location.protocol.startsWith("http") &&
!window.location.hostname.startsWith("wails");

try {
setLoading(true);
Expand Down Expand Up @@ -85,6 +87,7 @@ export function BackupNode() {
<AlertTriangleIcon className="h-4 w-4" />
<AlertTitle>Do not run your node on multiple devices</AlertTitle>
<AlertDescription>
{window.location.hostname}
Your node maintains channel state with your channel partners. After
you create this backup, do not restart Alby Hub on this device.
</AlertDescription>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/screens/setup/RestoreNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export function RestoreNode() {
const [loading, setLoading] = useState(false);
const [restored, setRestored] = useState(false);
const { data: info } = useInfo(restored);
const isHttpMode = window.location.protocol.startsWith("http");
const isHttpMode =
window.location.protocol.startsWith("http") &&
!window.location.hostname.startsWith("wails");

React.useEffect(() => {
if (restored && info?.setupCompleted) {
Expand Down

0 comments on commit ead2439

Please sign in to comment.