Skip to content

Commit 6f45c3b

Browse files
committed
fix: use current window url instead of app url in frontend
1 parent ff2dd81 commit 6f45c3b

File tree

12 files changed

+24
-56
lines changed

12 files changed

+24
-56
lines changed

frontend/src/components/account/showReverseShareLinkModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import { translateOutsideContext } from "../../hooks/useTranslate.hook";
55
const showReverseShareLinkModal = (
66
modals: ModalsContextProps,
77
reverseShareToken: string,
8-
appUrl: string,
98
) => {
109
const t = translateOutsideContext();
11-
const link = `${appUrl}/upload/${reverseShareToken}`;
10+
const link = `${window.location.origin}/upload/${reverseShareToken}`;
1211
return modals.openModal({
1312
title: t("account.reverseShares.modal.reverse-share-link"),
1413
children: (

frontend/src/components/account/showShareInformationsModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import CopyTextField from "../upload/CopyTextField";
1111
const showShareInformationsModal = (
1212
modals: ModalsContextProps,
1313
share: MyShare,
14-
appUrl: string,
1514
maxShareSize: number,
1615
) => {
1716
const t = translateOutsideContext();
18-
const link = `${appUrl}/s/${share.id}`;
17+
const link = `${window.location.origin}/s/${share.id}`;
1918

2019
const formattedShareSize = byteToHumanSizeString(share.size);
2120
const formattedMaxShareSize = byteToHumanSizeString(maxShareSize);

frontend/src/components/account/showShareLinkModal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import { Stack, TextInput } from "@mantine/core";
22
import { ModalsContextProps } from "@mantine/modals/lib/context";
33
import { translateOutsideContext } from "../../hooks/useTranslate.hook";
44

5-
const showShareLinkModal = (
6-
modals: ModalsContextProps,
7-
shareId: string,
8-
appUrl: string,
9-
) => {
5+
const showShareLinkModal = (modals: ModalsContextProps, shareId: string) => {
106
const t = translateOutsideContext();
11-
const link = `${appUrl}/s/${shareId}`;
7+
const link = `${window.location.origin}/s/${shareId}`;
128
return modals.openModal({
139
title: t("account.shares.modal.share-link"),
1410
children: (

frontend/src/components/admin/shares/ManageShareTable.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,11 @@ const ManageShareTable = ({
8989
onClick={() => {
9090
if (window.isSecureContext) {
9191
clipboard.copy(
92-
`${config.get("general.appUrl")}/s/${share.id}`,
92+
`${window.location.origin}/s/${share.id}`,
9393
);
9494
toast.success(t("common.notify.copied"));
9595
} else {
96-
showShareLinkModal(
97-
modals,
98-
share.id,
99-
config.get("general.appUrl"),
100-
);
96+
showShareLinkModal(modals, share.id);
10197
}
10298
}}
10399
>

frontend/src/components/auth/SignInForm.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
128128
config.get("oauth.disablePassword")
129129
) {
130130
setIsRedirectingToOauthProvider(true);
131-
router.push(
132-
getOAuthUrl(config.get("general.appUrl"), providers.data[0]),
133-
);
131+
router.push(getOAuthUrl(window.location.origin, providers.data[0]));
134132
}
135133
})
136134
.catch(toast.axiosError);
@@ -208,7 +206,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
208206
key={provider}
209207
component="a"
210208
title={t(`signIn.oauth.${provider}`)}
211-
href={getOAuthUrl(config.get("general.appUrl"), provider)}
209+
href={getOAuthUrl(window.location.origin, provider)}
212210
variant="light"
213211
fullWidth
214212
>

frontend/src/components/share/FileList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const FileList = ({
6565
};
6666

6767
const copyFileLink = (file: FileMetaData) => {
68-
const link = `${config.get("general.appUrl")}/api/shares/${
68+
const link = `${window.location.origin}/api/shares/${
6969
share.id
7070
}/files/${file.id}`;
7171

frontend/src/components/upload/modals/showCompletedUploadModal.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,25 @@ import CopyTextField from "../CopyTextField";
1313
const showCompletedUploadModal = (
1414
modals: ModalsContextProps,
1515
share: CompletedShare,
16-
appUrl: string,
1716
) => {
1817
const t = translateOutsideContext();
1918
return modals.openModal({
2019
closeOnClickOutside: false,
2120
withCloseButton: false,
2221
closeOnEscape: false,
2322
title: t("upload.modal.completed.share-ready"),
24-
children: <Body share={share} appUrl={appUrl} />,
23+
children: <Body share={share} />,
2524
});
2625
};
2726

28-
const Body = ({ share, appUrl }: { share: CompletedShare; appUrl: string }) => {
27+
const Body = ({ share }: { share: CompletedShare }) => {
2928
const modals = useModals();
3029
const router = useRouter();
3130
const t = useTranslate();
3231

3332
const isReverseShare = !!router.query["reverseShareToken"];
3433

35-
const link = `${appUrl}/s/${share.id}`;
34+
const link = `${window.location.origin}/s/${share.id}`;
3635

3736
return (
3837
<Stack align="stretch">

frontend/src/components/upload/modals/showCreateUploadModal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useForm, yupResolver } from "@mantine/form";
1919
import { useModals } from "@mantine/modals";
2020
import { ModalsContextProps } from "@mantine/modals/lib/context";
2121
import moment from "moment";
22-
import { useState } from "react";
22+
import React, { useState } from "react";
2323
import { TbAlertCircle } from "react-icons/tb";
2424
import { FormattedMessage } from "react-intl";
2525
import * as yup from "yup";
@@ -30,15 +30,13 @@ import shareService from "../../../services/share.service";
3030
import { FileUpload } from "../../../types/File.type";
3131
import { CreateShare } from "../../../types/share.type";
3232
import { getExpirationPreview } from "../../../utils/date.util";
33-
import React from "react";
3433
import toast from "../../../utils/toast.util";
3534

3635
const showCreateUploadModal = (
3736
modals: ModalsContextProps,
3837
options: {
3938
isUserSignedIn: boolean;
4039
isReverseShare: boolean;
41-
appUrl: string;
4240
allowUnauthenticatedShares: boolean;
4341
enableEmailRecepients: boolean;
4442
maxExpirationInHours: number;
@@ -101,7 +99,6 @@ const CreateUploadModalBody = ({
10199
options: {
102100
isUserSignedIn: boolean;
103101
isReverseShare: boolean;
104-
appUrl: string;
105102
allowUnauthenticatedShares: boolean;
106103
enableEmailRecepients: boolean;
107104
maxExpirationInHours: number;
@@ -245,7 +242,7 @@ const CreateUploadModalBody = ({
245242
color: theme.colors.gray[6],
246243
})}
247244
>
248-
{`${options.appUrl}/s/${form.values.link}`}
245+
{`${window.location.origin}/s/${form.values.link}`}
249246
</Text>
250247
{!options.isReverseShare && (
251248
<>
@@ -461,7 +458,6 @@ const SimplifiedCreateUploadModalModal = ({
461458
options: {
462459
isUserSignedIn: boolean;
463460
isReverseShare: boolean;
464-
appUrl: string;
465461
allowUnauthenticatedShares: boolean;
466462
enableEmailRecepients: boolean;
467463
maxExpirationInHours: number;

frontend/src/pages/account/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ const Account = () => {
279279
) : (
280280
<Button
281281
component="a"
282-
href={getOAuthUrl(
283-
config.get("general.appUrl"),
284-
provider,
285-
)}
282+
href={getOAuthUrl(window.location.origin, provider)}
286283
>
287284
{t("account.card.oauth.link")}
288285
</Button>

frontend/src/pages/account/reverseShares.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ const MyShares = () => {
3737

3838
const config = useConfig();
3939

40-
const appUrl = config.get("general.appUrl");
41-
4240
const [reverseShares, setReverseShares] = useState<MyReverseShare[]>();
4341

4442
const getReverseShares = () => {
@@ -146,7 +144,7 @@ const MyShares = () => {
146144
{reverseShare.shares.map((share) => (
147145
<Group key={share.id} mb={4}>
148146
<Anchor
149-
href={`${appUrl}/share/${share.id}`}
147+
href={`${window.location.origin}/share/${share.id}`}
150148
target="_blank"
151149
>
152150
<Text maw={120} truncate>
@@ -159,14 +157,12 @@ const MyShares = () => {
159157
size={25}
160158
onClick={() => {
161159
if (window.isSecureContext) {
162-
clipboard.copy(`${appUrl}/s/${share.id}`);
160+
clipboard.copy(
161+
`${window.location.origin}/s/${share.id}`,
162+
);
163163
toast.success(t("common.notify.copied"));
164164
} else {
165-
showShareLinkModal(
166-
modals,
167-
share.id,
168-
config.get("general.appUrl"),
169-
);
165+
showShareLinkModal(modals, share.id);
170166
}
171167
}}
172168
>
@@ -197,7 +193,7 @@ const MyShares = () => {
197193
onClick={() => {
198194
if (window.isSecureContext) {
199195
clipboard.copy(
200-
`${config.get("general.appUrl")}/upload/${
196+
`${window.location.origin}/upload/${
201197
reverseShare.token
202198
}`,
203199
);
@@ -206,7 +202,6 @@ const MyShares = () => {
206202
showReverseShareLinkModal(
207203
modals,
208204
reverseShare.token,
209-
config.get("general.appUrl"),
210205
);
211206
}
212207
}}

frontend/src/pages/account/shares.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Button,
55
Center,
66
Group,
7-
MediaQuery,
87
Space,
98
Stack,
109
Table,
@@ -109,7 +108,6 @@ const MyShares = () => {
109108
showShareInformationsModal(
110109
modals,
111110
share,
112-
config.get("general.appUrl"),
113111
parseInt(config.get("share.maxSize")),
114112
);
115113
}}
@@ -123,15 +121,11 @@ const MyShares = () => {
123121
onClick={() => {
124122
if (window.isSecureContext) {
125123
clipboard.copy(
126-
`${config.get("general.appUrl")}/s/${share.id}`,
124+
`${window.location.origin}/s/${share.id}`,
127125
);
128126
toast.success(t("common.notify.copied"));
129127
} else {
130-
showShareLinkModal(
131-
modals,
132-
share.id,
133-
config.get("general.appUrl"),
134-
);
128+
showShareLinkModal(modals, share.id);
135129
}
136130
}}
137131
>

frontend/src/pages/upload/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ const Upload = ({
135135
{
136136
isUserSignedIn: user ? true : false,
137137
isReverseShare,
138-
appUrl: config.get("general.appUrl"),
139138
allowUnauthenticatedShares: config.get(
140139
"share.allowUnauthenticatedShares",
141140
),
@@ -189,7 +188,7 @@ const Upload = ({
189188
.completeShare(createdShare.id)
190189
.then((share) => {
191190
setisUploading(false);
192-
showCompletedUploadModal(modals, share, config.get("general.appUrl"));
191+
showCompletedUploadModal(modals, share);
193192
setFiles([]);
194193
})
195194
.catch(() => toast.error(t("upload.notify.generic-error")));

0 commit comments

Comments
 (0)