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;
|
||||
|
||||
Reference in New Issue
Block a user