diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index a6f4f7ae..8216329a 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -20,11 +20,6 @@ const configVariables: ConfigVariables = { defaultValue: "http://localhost:3000", secret: false, }, - webroot: { - type: "string", - defaultValue: "", - secret: false, - }, showHomePage: { type: "boolean", defaultValue: "true", diff --git a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx index 2b7b50da..057ac76c 100644 --- a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx @@ -13,6 +13,8 @@ import { FormattedMessage } from "react-intl"; import useConfig from "../../../hooks/config.hook"; import Logo from "../../Logo"; +const webroot = process.env.WEBROOT || ""; + const ConfigurationHeader = ({ isMobileNavBarOpened, setIsMobileNavBarOpened, @@ -42,7 +44,7 @@ const ConfigurationHeader = ({ - diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index 615ff090..f2bece58 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -15,6 +15,8 @@ import { TbAt, TbMail, TbShare, TbSocial, TbSquare } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; import useConfig from "../../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const categories = [ { name: "General", icon: }, { name: "Email", icon: }, @@ -71,7 +73,7 @@ const ConfigurationNavBar = ({ : undefined } key={category.name} - href={`${config.get("general.webroot")}/admin/config/${category.name.toLowerCase()}`} + href={`${webroot}/admin/config/${category.name.toLowerCase()}`} > - diff --git a/frontend/src/components/auth/SignInForm.tsx b/frontend/src/components/auth/SignInForm.tsx index ab24ca49..87aa8260 100644 --- a/frontend/src/components/auth/SignInForm.tsx +++ b/frontend/src/components/auth/SignInForm.tsx @@ -26,6 +26,8 @@ import authService from "../../services/auth.service"; import { getOAuthIcon, getOAuthUrl } from "../../utils/oauth.util"; import toast from "../../utils/toast.util"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ or: { "&:before": { @@ -145,7 +147,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => { /> {config.get("smtp.enabled") && ( - + diff --git a/frontend/src/components/header/ActionAvatar.tsx b/frontend/src/components/header/ActionAvatar.tsx index 3805cad2..cf188ba8 100644 --- a/frontend/src/components/header/ActionAvatar.tsx +++ b/frontend/src/components/header/ActionAvatar.tsx @@ -6,6 +6,8 @@ import authService from "../../services/auth.service"; import { FormattedMessage, useIntl } from "react-intl"; import useConfig from "../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const ActionAvatar = () => { const { user } = useUser(); const config = useConfig(); @@ -18,13 +20,13 @@ const ActionAvatar = () => { - }> + }> {user!.isAdmin && ( } > diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index dcb70ddc..b6e801f9 100644 --- a/frontend/src/components/header/Header.tsx +++ b/frontend/src/components/header/Header.tsx @@ -22,6 +22,7 @@ import ActionAvatar from "./ActionAvatar"; import NavbarShareMenu from "./NavbarShareMenu"; const HEADER_HEIGHT = 60; +const webroot = process.env.WEBROOT || ""; type NavLink = { link?: string; @@ -125,7 +126,7 @@ const Header = () => { const authenticatedLinks: NavLink[] = [ { - link: config.get("general.webroot") + "/upload", + link: webroot + "/upload", label: t("navbar.upload"), }, { @@ -138,27 +139,27 @@ const Header = () => { let unauthenticatedLinks: NavLink[] = [ { - link: config.get("general.webroot") + "/auth/signIn", + link: webroot + "/auth/signIn", label: t("navbar.signin"), }, ]; if (config.get("share.allowUnauthenticatedShares")) { unauthenticatedLinks.unshift({ - link: config.get("general.webroot") + "/upload", + link: webroot + "/upload", label: t("navbar.upload"), }); } if (config.get("general.showHomePage")) unauthenticatedLinks.unshift({ - link: config.get("general.webroot") + "/", + link: webroot + "/", label: t("navbar.home"), }); if (config.get("share.allowRegistration")) unauthenticatedLinks.push({ - link: config.get("general.webroot") + "/auth/signUp", + link: webroot + "/auth/signUp", label: t("navbar.signup"), }); @@ -191,7 +192,7 @@ const Header = () => { return ( - + {config.get("general.appName")} diff --git a/frontend/src/components/header/NavbarShareMenu.tsx b/frontend/src/components/header/NavbarShareMenu.tsx index e54eab2e..9a70efeb 100644 --- a/frontend/src/components/header/NavbarShareMenu.tsx +++ b/frontend/src/components/header/NavbarShareMenu.tsx @@ -4,6 +4,8 @@ import { TbArrowLoopLeft, TbLink } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; import useConfig from "../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const NavbarShareMneu = () => { const config = useConfig(); return ( @@ -14,12 +16,12 @@ const NavbarShareMneu = () => { - }> + }> } > diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 1fded5cc..ee2af2ea 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -14,6 +14,7 @@ import api from "../../services/api.service"; import Markdown from "markdown-to-jsx"; import useConfig from "../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; const FilePreviewContext = React.createContext<{ shareId: string; @@ -51,7 +52,7 @@ const FilePreview = ({ component={Link} onClick={() => modals.closeAll()} target="_blank" - href={`${config.get("general.webroot")}/api/shares/${shareId}/files/${fileId}?download=false`} + href={`${webroot}/api/shares/${shareId}/files/${fileId}?download=false`} > View original file {/* Add translation? */} diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index 8358ae0e..61461721 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -11,6 +11,8 @@ import Meta from "../components/Meta"; import { FormattedMessage } from "react-intl"; import useConfig from "../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ root: { paddingTop: 80, @@ -54,7 +56,7 @@ const ErrorNotFound = () => { className={classes.description} > - diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index bbe75826..3013ecae 100644 --- a/frontend/src/pages/account/shares.tsx +++ b/frontend/src/pages/account/shares.tsx @@ -28,6 +28,8 @@ import shareService from "../../services/share.service"; import { MyShare } from "../../types/share.type"; import toast from "../../utils/toast.util"; +const webroot = process.env.WEBROOT || ""; + const MyShares = () => { const modals = useModals(); const clipboard = useClipboard(); @@ -58,7 +60,7 @@ const MyShares = () => { - diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 5e59ee64..29a8284d 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -12,6 +12,8 @@ import Logo from "../../components/Logo"; import Meta from "../../components/Meta"; import useConfig from "../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const Intro = () => { const config = useConfig(); return ( @@ -45,10 +47,10 @@ const Intro = () => { Enough talked, have fun with Pingvin Share! How to you want to continue? - - diff --git a/frontend/src/pages/auth/resetPassword/index.tsx b/frontend/src/pages/auth/resetPassword/index.tsx index 93753f9f..c7d938e8 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -22,6 +22,8 @@ import authService from "../../../services/auth.service"; import toast from "../../../utils/toast.util"; import useConfig from "../../../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ title: { fontSize: 26, @@ -95,7 +97,7 @@ const ResetPassword = () => { color="dimmed" size="sm" className={classes.control} - href={config.get("general.webroot") + "/auth/signIn"} + href={webroot + "/auth/signIn"} >
diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index d664b601..28d64aec 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -18,6 +18,8 @@ import Meta from "../components/Meta"; import useUser from "../hooks/user.hook"; import useConfig from "../hooks/config.hook"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ inner: { display: "flex", @@ -80,7 +82,7 @@ export default function Home() { useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace(config.get("general.webroot") + "/upload"); + router.replace(webroot + "/upload"); } }); }, []); @@ -144,7 +146,7 @@ export default function Home() {