fix: use current window url instead of app url in frontend
This commit is contained in:
@@ -5,10 +5,9 @@ import { translateOutsideContext } from "../../hooks/useTranslate.hook";
|
||||
const showReverseShareLinkModal = (
|
||||
modals: ModalsContextProps,
|
||||
reverseShareToken: string,
|
||||
appUrl: string,
|
||||
) => {
|
||||
const t = translateOutsideContext();
|
||||
const link = `${appUrl}/upload/${reverseShareToken}`;
|
||||
const link = `${window.location.origin}/upload/${reverseShareToken}`;
|
||||
return modals.openModal({
|
||||
title: t("account.reverseShares.modal.reverse-share-link"),
|
||||
children: (
|
||||
|
||||
@@ -11,11 +11,10 @@ import CopyTextField from "../upload/CopyTextField";
|
||||
const showShareInformationsModal = (
|
||||
modals: ModalsContextProps,
|
||||
share: MyShare,
|
||||
appUrl: string,
|
||||
maxShareSize: number,
|
||||
) => {
|
||||
const t = translateOutsideContext();
|
||||
const link = `${appUrl}/s/${share.id}`;
|
||||
const link = `${window.location.origin}/s/${share.id}`;
|
||||
|
||||
const formattedShareSize = byteToHumanSizeString(share.size);
|
||||
const formattedMaxShareSize = byteToHumanSizeString(maxShareSize);
|
||||
|
||||
@@ -2,13 +2,9 @@ import { Stack, TextInput } from "@mantine/core";
|
||||
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
||||
import { translateOutsideContext } from "../../hooks/useTranslate.hook";
|
||||
|
||||
const showShareLinkModal = (
|
||||
modals: ModalsContextProps,
|
||||
shareId: string,
|
||||
appUrl: string,
|
||||
) => {
|
||||
const showShareLinkModal = (modals: ModalsContextProps, shareId: string) => {
|
||||
const t = translateOutsideContext();
|
||||
const link = `${appUrl}/s/${shareId}`;
|
||||
const link = `${window.location.origin}/s/${shareId}`;
|
||||
return modals.openModal({
|
||||
title: t("account.shares.modal.share-link"),
|
||||
children: (
|
||||
|
||||
@@ -89,15 +89,11 @@ const ManageShareTable = ({
|
||||
onClick={() => {
|
||||
if (window.isSecureContext) {
|
||||
clipboard.copy(
|
||||
`${config.get("general.appUrl")}/s/${share.id}`,
|
||||
`${window.location.origin}/s/${share.id}`,
|
||||
);
|
||||
toast.success(t("common.notify.copied"));
|
||||
} else {
|
||||
showShareLinkModal(
|
||||
modals,
|
||||
share.id,
|
||||
config.get("general.appUrl"),
|
||||
);
|
||||
showShareLinkModal(modals, share.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -128,9 +128,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
|
||||
config.get("oauth.disablePassword")
|
||||
) {
|
||||
setIsRedirectingToOauthProvider(true);
|
||||
router.push(
|
||||
getOAuthUrl(config.get("general.appUrl"), providers.data[0]),
|
||||
);
|
||||
router.push(getOAuthUrl(window.location.origin, providers.data[0]));
|
||||
}
|
||||
})
|
||||
.catch(toast.axiosError);
|
||||
@@ -208,7 +206,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => {
|
||||
key={provider}
|
||||
component="a"
|
||||
title={t(`signIn.oauth.${provider}`)}
|
||||
href={getOAuthUrl(config.get("general.appUrl"), provider)}
|
||||
href={getOAuthUrl(window.location.origin, provider)}
|
||||
variant="light"
|
||||
fullWidth
|
||||
>
|
||||
|
||||
@@ -65,7 +65,7 @@ const FileList = ({
|
||||
};
|
||||
|
||||
const copyFileLink = (file: FileMetaData) => {
|
||||
const link = `${config.get("general.appUrl")}/api/shares/${
|
||||
const link = `${window.location.origin}/api/shares/${
|
||||
share.id
|
||||
}/files/${file.id}`;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import CopyTextField from "../CopyTextField";
|
||||
const showCompletedUploadModal = (
|
||||
modals: ModalsContextProps,
|
||||
share: CompletedShare,
|
||||
appUrl: string,
|
||||
) => {
|
||||
const t = translateOutsideContext();
|
||||
return modals.openModal({
|
||||
@@ -21,18 +20,18 @@ const showCompletedUploadModal = (
|
||||
withCloseButton: false,
|
||||
closeOnEscape: false,
|
||||
title: t("upload.modal.completed.share-ready"),
|
||||
children: <Body share={share} appUrl={appUrl} />,
|
||||
children: <Body share={share} />,
|
||||
});
|
||||
};
|
||||
|
||||
const Body = ({ share, appUrl }: { share: CompletedShare; appUrl: string }) => {
|
||||
const Body = ({ share }: { share: CompletedShare }) => {
|
||||
const modals = useModals();
|
||||
const router = useRouter();
|
||||
const t = useTranslate();
|
||||
|
||||
const isReverseShare = !!router.query["reverseShareToken"];
|
||||
|
||||
const link = `${appUrl}/s/${share.id}`;
|
||||
const link = `${window.location.origin}/s/${share.id}`;
|
||||
|
||||
return (
|
||||
<Stack align="stretch">
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useForm, yupResolver } from "@mantine/form";
|
||||
import { useModals } from "@mantine/modals";
|
||||
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
||||
import moment from "moment";
|
||||
import { useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { TbAlertCircle } from "react-icons/tb";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import * as yup from "yup";
|
||||
@@ -30,7 +30,6 @@ import shareService from "../../../services/share.service";
|
||||
import { FileUpload } from "../../../types/File.type";
|
||||
import { CreateShare } from "../../../types/share.type";
|
||||
import { getExpirationPreview } from "../../../utils/date.util";
|
||||
import React from "react";
|
||||
import toast from "../../../utils/toast.util";
|
||||
|
||||
const showCreateUploadModal = (
|
||||
@@ -38,7 +37,6 @@ const showCreateUploadModal = (
|
||||
options: {
|
||||
isUserSignedIn: boolean;
|
||||
isReverseShare: boolean;
|
||||
appUrl: string;
|
||||
allowUnauthenticatedShares: boolean;
|
||||
enableEmailRecepients: boolean;
|
||||
maxExpirationInHours: number;
|
||||
@@ -101,7 +99,6 @@ const CreateUploadModalBody = ({
|
||||
options: {
|
||||
isUserSignedIn: boolean;
|
||||
isReverseShare: boolean;
|
||||
appUrl: string;
|
||||
allowUnauthenticatedShares: boolean;
|
||||
enableEmailRecepients: boolean;
|
||||
maxExpirationInHours: number;
|
||||
@@ -245,7 +242,7 @@ const CreateUploadModalBody = ({
|
||||
color: theme.colors.gray[6],
|
||||
})}
|
||||
>
|
||||
{`${options.appUrl}/s/${form.values.link}`}
|
||||
{`${window.location.origin}/s/${form.values.link}`}
|
||||
</Text>
|
||||
{!options.isReverseShare && (
|
||||
<>
|
||||
@@ -461,7 +458,6 @@ const SimplifiedCreateUploadModalModal = ({
|
||||
options: {
|
||||
isUserSignedIn: boolean;
|
||||
isReverseShare: boolean;
|
||||
appUrl: string;
|
||||
allowUnauthenticatedShares: boolean;
|
||||
enableEmailRecepients: boolean;
|
||||
maxExpirationInHours: number;
|
||||
|
||||
@@ -279,10 +279,7 @@ const Account = () => {
|
||||
) : (
|
||||
<Button
|
||||
component="a"
|
||||
href={getOAuthUrl(
|
||||
config.get("general.appUrl"),
|
||||
provider,
|
||||
)}
|
||||
href={getOAuthUrl(window.location.origin, provider)}
|
||||
>
|
||||
{t("account.card.oauth.link")}
|
||||
</Button>
|
||||
|
||||
@@ -37,8 +37,6 @@ const MyShares = () => {
|
||||
|
||||
const config = useConfig();
|
||||
|
||||
const appUrl = config.get("general.appUrl");
|
||||
|
||||
const [reverseShares, setReverseShares] = useState<MyReverseShare[]>();
|
||||
|
||||
const getReverseShares = () => {
|
||||
@@ -146,7 +144,7 @@ const MyShares = () => {
|
||||
{reverseShare.shares.map((share) => (
|
||||
<Group key={share.id} mb={4}>
|
||||
<Anchor
|
||||
href={`${appUrl}/share/${share.id}`}
|
||||
href={`${window.location.origin}/share/${share.id}`}
|
||||
target="_blank"
|
||||
>
|
||||
<Text maw={120} truncate>
|
||||
@@ -159,14 +157,12 @@ const MyShares = () => {
|
||||
size={25}
|
||||
onClick={() => {
|
||||
if (window.isSecureContext) {
|
||||
clipboard.copy(`${appUrl}/s/${share.id}`);
|
||||
clipboard.copy(
|
||||
`${window.location.origin}/s/${share.id}`,
|
||||
);
|
||||
toast.success(t("common.notify.copied"));
|
||||
} else {
|
||||
showShareLinkModal(
|
||||
modals,
|
||||
share.id,
|
||||
config.get("general.appUrl"),
|
||||
);
|
||||
showShareLinkModal(modals, share.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
@@ -197,7 +193,7 @@ const MyShares = () => {
|
||||
onClick={() => {
|
||||
if (window.isSecureContext) {
|
||||
clipboard.copy(
|
||||
`${config.get("general.appUrl")}/upload/${
|
||||
`${window.location.origin}/upload/${
|
||||
reverseShare.token
|
||||
}`,
|
||||
);
|
||||
@@ -206,7 +202,6 @@ const MyShares = () => {
|
||||
showReverseShareLinkModal(
|
||||
modals,
|
||||
reverseShare.token,
|
||||
config.get("general.appUrl"),
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
MediaQuery,
|
||||
Space,
|
||||
Stack,
|
||||
Table,
|
||||
@@ -109,7 +108,6 @@ const MyShares = () => {
|
||||
showShareInformationsModal(
|
||||
modals,
|
||||
share,
|
||||
config.get("general.appUrl"),
|
||||
parseInt(config.get("share.maxSize")),
|
||||
);
|
||||
}}
|
||||
@@ -123,15 +121,11 @@ const MyShares = () => {
|
||||
onClick={() => {
|
||||
if (window.isSecureContext) {
|
||||
clipboard.copy(
|
||||
`${config.get("general.appUrl")}/s/${share.id}`,
|
||||
`${window.location.origin}/s/${share.id}`,
|
||||
);
|
||||
toast.success(t("common.notify.copied"));
|
||||
} else {
|
||||
showShareLinkModal(
|
||||
modals,
|
||||
share.id,
|
||||
config.get("general.appUrl"),
|
||||
);
|
||||
showShareLinkModal(modals, share.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -135,7 +135,6 @@ const Upload = ({
|
||||
{
|
||||
isUserSignedIn: user ? true : false,
|
||||
isReverseShare,
|
||||
appUrl: config.get("general.appUrl"),
|
||||
allowUnauthenticatedShares: config.get(
|
||||
"share.allowUnauthenticatedShares",
|
||||
),
|
||||
@@ -189,7 +188,7 @@ const Upload = ({
|
||||
.completeShare(createdShare.id)
|
||||
.then((share) => {
|
||||
setisUploading(false);
|
||||
showCompletedUploadModal(modals, share, config.get("general.appUrl"));
|
||||
showCompletedUploadModal(modals, share);
|
||||
setFiles([]);
|
||||
})
|
||||
.catch(() => toast.error(t("upload.notify.generic-error")));
|
||||
|
||||
Reference in New Issue
Block a user