From 8a5849dedb4d03f8597bd1ee55dcde6ad565bfec Mon Sep 17 00:00:00 2001 From: gluzzati Date: Thu, 21 Mar 2024 16:48:35 +0000 Subject: [PATCH 01/14] appUrl prefix --- .../admin/configuration/ConfigurationHeader.tsx | 2 +- .../admin/configuration/ConfigurationNavBar.tsx | 6 ++++-- frontend/src/components/auth/SignInForm.tsx | 2 +- frontend/src/components/header/ActionAvatar.tsx | 6 ++++-- frontend/src/components/header/Header.tsx | 12 ++++++------ frontend/src/components/header/NavbarShareMenu.tsx | 6 ++++-- frontend/src/components/share/FilePreview.tsx | 5 +++-- frontend/src/pages/404.tsx | 5 +++-- frontend/src/pages/account/shares.tsx | 2 +- frontend/src/pages/admin/intro.tsx | 6 ++++-- frontend/src/pages/auth/resetPassword/index.tsx | 4 +++- frontend/src/pages/index.tsx | 6 ++++-- 12 files changed, 38 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx index a78dce1..8bb6caa 100644 --- a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx @@ -42,7 +42,7 @@ const ConfigurationHeader = ({ - diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index 9df1a19..dfd21ec 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -13,6 +13,7 @@ import Link from "next/link"; import { Dispatch, SetStateAction } from "react"; import { TbAt, TbMail, TbShare, TbSocial, TbSquare } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; +import useConfig from "../../../hooks/config.hook"; const categories = [ { name: "General", icon: }, @@ -46,6 +47,7 @@ const ConfigurationNavBar = ({ setIsMobileNavBarOpened: Dispatch>; }) => { const { classes } = useStyles(); + const config = useConfig(); return ( - diff --git a/frontend/src/components/auth/SignInForm.tsx b/frontend/src/components/auth/SignInForm.tsx index e5bd96b..98394d7 100644 --- a/frontend/src/components/auth/SignInForm.tsx +++ b/frontend/src/components/auth/SignInForm.tsx @@ -145,7 +145,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 414c5a0..818032e 100644 --- a/frontend/src/components/header/ActionAvatar.tsx +++ b/frontend/src/components/header/ActionAvatar.tsx @@ -4,9 +4,11 @@ import { TbDoorExit, TbSettings, TbUser } from "react-icons/tb"; import useUser from "../../hooks/user.hook"; import authService from "../../services/auth.service"; import { FormattedMessage, useIntl } from "react-intl"; +import useConfig from "../../hooks/config.hook"; const ActionAvatar = () => { const { user } = useUser(); + const config = useConfig(); return ( @@ -16,13 +18,13 @@ const ActionAvatar = () => { - }> + }> {user!.isAdmin && ( } > diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index d633104..2271ac3 100644 --- a/frontend/src/components/header/Header.tsx +++ b/frontend/src/components/header/Header.tsx @@ -125,7 +125,7 @@ const Header = () => { const authenticatedLinks: NavLink[] = [ { - link: "/upload", + link: config.get("general.appUrl") + "/upload", label: t("navbar.upload"), }, { @@ -138,27 +138,27 @@ const Header = () => { let unauthenticatedLinks: NavLink[] = [ { - link: "/auth/signIn", + link: config.get("general.appUrl") + "/auth/signIn", label: t("navbar.signin"), }, ]; if (config.get("share.allowUnauthenticatedShares")) { unauthenticatedLinks.unshift({ - link: "/upload", + link: config.get("general.appUrl") + "/upload", label: t("navbar.upload"), }); } if (config.get("general.showHomePage")) unauthenticatedLinks.unshift({ - link: "/", + link: config.get("general.appUrl") + "/", label: t("navbar.home"), }); if (config.get("share.allowRegistration")) unauthenticatedLinks.push({ - link: "/auth/signUp", + link: config.get("general.appUrl") + "/auth/signUp", label: t("navbar.signup"), }); @@ -191,7 +191,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 56775dc..2ba8153 100644 --- a/frontend/src/components/header/NavbarShareMenu.tsx +++ b/frontend/src/components/header/NavbarShareMenu.tsx @@ -2,8 +2,10 @@ import { ActionIcon, Menu } from "@mantine/core"; import Link from "next/link"; import { TbArrowLoopLeft, TbLink } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; +import useConfig from "../../hooks/config.hook"; const NavbarShareMneu = () => { + const config = useConfig(); return ( @@ -12,12 +14,12 @@ const NavbarShareMneu = () => { - }> + }> } > diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 71606ff..0d06f9c 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -12,6 +12,7 @@ import React, { Dispatch, SetStateAction, useEffect, useState } from "react"; import { FormattedMessage } from "react-intl"; import api from "../../services/api.service"; import Markdown from "markdown-to-jsx"; +import useConfig from "../../hooks/config.hook"; const FilePreviewContext = React.createContext<{ shareId: string; @@ -36,7 +37,7 @@ const FilePreview = ({ }) => { const [isNotSupported, setIsNotSupported] = useState(false); if (isNotSupported) return ; - + const config = useConfig(); return ( modals.closeAll()} target="_blank" - href={`/api/shares/${shareId}/files/${fileId}?download=false`} + href={`${config.get("general.appUrl")}/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 99a50aa..ebd5cc8 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -9,6 +9,7 @@ import { import Link from "next/link"; import Meta from "../components/Meta"; import { FormattedMessage } from "react-intl"; +import useConfig from "../hooks/config.hook"; const useStyles = createStyles((theme) => ({ root: { @@ -38,7 +39,7 @@ const useStyles = createStyles((theme) => ({ const ErrorNotFound = () => { const { classes } = useStyles(); - + const config = useConfig(); return ( <> @@ -53,7 +54,7 @@ const ErrorNotFound = () => { className={classes.description} > - diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index 9edb228..7c0b3ea 100644 --- a/frontend/src/pages/account/shares.tsx +++ b/frontend/src/pages/account/shares.tsx @@ -58,7 +58,7 @@ const MyShares = () => { - diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 59833fd..79b3d6d 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -10,8 +10,10 @@ import { import Link from "next/link"; import Logo from "../../components/Logo"; import Meta from "../../components/Meta"; +import useConfig from "../../hooks/config.hook"; const Intro = () => { + const config = useConfig(); return ( <> @@ -43,10 +45,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 2ac8e08..4062ca6 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -20,6 +20,7 @@ import * as yup from "yup"; import useTranslate from "../../../hooks/useTranslate.hook"; import authService from "../../../services/auth.service"; import toast from "../../../utils/toast.util"; +import useConfig from "../../../hooks/config.hook"; const useStyles = createStyles((theme) => ({ title: { @@ -61,6 +62,7 @@ const ResetPassword = () => { ), }); + const config = useConfig(); return ( @@ -93,7 +95,7 @@ const ResetPassword = () => { color="dimmed" size="sm" className={classes.control} - href={"/auth/signIn"} + href={config.get("general.appUrl") + "/auth/signIn"} > <Center inline> <TbArrowLeft size={12} /> diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 227fad7..d9e7c7c 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -16,6 +16,7 @@ import { FormattedMessage } from "react-intl"; import Logo from "../components/Logo"; import Meta from "../components/Meta"; import useUser from "../hooks/user.hook"; +import useConfig from "../hooks/config.hook"; const useStyles = createStyles((theme) => ({ inner: { @@ -73,12 +74,13 @@ export default function Home() { const { classes } = useStyles(); const { refreshUser } = useUser(); const router = useRouter(); + const config = useConfig(); // If the user is already logged in, redirect to the upload page useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace("/upload"); + router.replace(config.get("general.appUrl") + "/upload"); } }); }, []); @@ -142,7 +144,7 @@ export default function Home() { <Group mt={30}> <Button component={Link} - href="/auth/signUp" + href={config.get("general.appUrl") + "/auth/signUp"} radius="xl" size="md" className={classes.control} From 410c4930ef97a00f9ea7288d18002f3d4e66734c Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Thu, 21 Mar 2024 18:26:57 +0000 Subject: [PATCH 02/14] avoid conditional declare config --- frontend/src/components/share/FilePreview.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 0d06f9c..43b8f1b 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 FilePreviewContext = React.createContext<{ shareId: string; fileId: string; @@ -36,8 +37,8 @@ const FilePreview = ({ mimeType: string; }) => { const [isNotSupported, setIsNotSupported] = useState(false); - if (isNotSupported) return <UnSupportedFile />; const config = useConfig(); + if (isNotSupported) return <UnSupportedFile />; return ( <Stack> <FilePreviewContext.Provider From 7d93cc6c63e7257b7aaebda8e7fc9c9b61a6a710 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Thu, 21 Mar 2024 18:29:49 +0000 Subject: [PATCH 03/14] use config --- .../src/components/admin/configuration/ConfigurationNavBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index dfd21ec..39847d8 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -94,7 +94,7 @@ const ConfigurationNavBar = ({ </Stack> </Navbar.Section> <MediaQuery largerThan="sm" styles={{ display: "none" }}> - <Button mt="xl" variant="light" component={Link} href={webroot + "/admin"}> + <Button mt="xl" variant="light" component={Link} href={config.get("general.appUrl") + "/admin"}> <FormattedMessage id="common.button.go-back" /> </Button> </MediaQuery> From 231876e7946da17e5f67333ead36571dfdd56b30 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Thu, 21 Mar 2024 20:31:25 +0000 Subject: [PATCH 04/14] use config.webroot --- frontend/next.config.js | 1 + .../admin/configuration/ConfigurationHeader.tsx | 2 +- .../admin/configuration/ConfigurationNavBar.tsx | 4 ++-- frontend/src/components/auth/SignInForm.tsx | 2 +- frontend/src/components/header/ActionAvatar.tsx | 4 ++-- frontend/src/components/header/Header.tsx | 12 ++++++------ frontend/src/components/header/NavbarShareMenu.tsx | 4 ++-- frontend/src/components/share/FilePreview.tsx | 2 +- frontend/src/pages/404.tsx | 2 +- frontend/src/pages/account/shares.tsx | 2 +- frontend/src/pages/admin/intro.tsx | 4 ++-- frontend/src/pages/auth/resetPassword/index.tsx | 2 +- frontend/src/pages/index.tsx | 4 ++-- 13 files changed, 23 insertions(+), 22 deletions(-) diff --git a/frontend/next.config.js b/frontend/next.config.js index 808c0d5..e3202d8 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -20,5 +20,6 @@ module.exports = withPWA({ }, serverRuntimeConfig: { apiURL: process.env.API_URL ?? 'http://localhost:8080', + webroot: process.env.WEBROOT ?? '', }, }); diff --git a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx index 8bb6caa..2b7b50d 100644 --- a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx @@ -42,7 +42,7 @@ const ConfigurationHeader = ({ </Group> </Link> <MediaQuery smallerThan="sm" styles={{ display: "none" }}> - <Button variant="light" component={Link} href={config.get("general.appUrl") + "/admin"}> + <Button variant="light" component={Link} href={config.get("general.webroot") + "/admin"}> <FormattedMessage id="common.button.go-back" /> </Button> </MediaQuery> diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index 39847d8..615ff09 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -71,7 +71,7 @@ const ConfigurationNavBar = ({ : undefined } key={category.name} - href={`${config.get("general.appUrl")}/admin/config/${category.name.toLowerCase()}`} + href={`${config.get("general.webroot")}/admin/config/${category.name.toLowerCase()}`} > <Group> <ThemeIcon @@ -94,7 +94,7 @@ const ConfigurationNavBar = ({ </Stack> </Navbar.Section> <MediaQuery largerThan="sm" styles={{ display: "none" }}> - <Button mt="xl" variant="light" component={Link} href={config.get("general.appUrl") + "/admin"}> + <Button mt="xl" variant="light" component={Link} href={config.get("general.webroot") + "/admin"}> <FormattedMessage id="common.button.go-back" /> </Button> </MediaQuery> diff --git a/frontend/src/components/auth/SignInForm.tsx b/frontend/src/components/auth/SignInForm.tsx index 98394d7..ab24ca4 100644 --- a/frontend/src/components/auth/SignInForm.tsx +++ b/frontend/src/components/auth/SignInForm.tsx @@ -145,7 +145,7 @@ const SignInForm = ({ redirectPath }: { redirectPath: string }) => { /> {config.get("smtp.enabled") && ( <Group position="right" mt="xs"> - <Anchor component={Link} href={config.get("general.appUrl") + "/auth/resetPassword"} size="xs"> + <Anchor component={Link} href={config.get("general.webroot") + "/auth/resetPassword"} size="xs"> <FormattedMessage id="resetPassword.title" /> </Anchor> </Group> diff --git a/frontend/src/components/header/ActionAvatar.tsx b/frontend/src/components/header/ActionAvatar.tsx index 818032e..3805cad 100644 --- a/frontend/src/components/header/ActionAvatar.tsx +++ b/frontend/src/components/header/ActionAvatar.tsx @@ -18,13 +18,13 @@ const ActionAvatar = () => { </ActionIcon> </Menu.Target> <Menu.Dropdown> - <Menu.Item component={Link} href={config.get("general.appUrl") + "/account"} icon={<TbUser size={14} />}> + <Menu.Item component={Link} href={config.get("general.webroot") + "/account"} icon={<TbUser size={14} />}> <FormattedMessage id="navbar.avatar.account" /> </Menu.Item> {user!.isAdmin && ( <Menu.Item component={Link} - href={config.get("general.appUrl") + "/admin"} + href={config.get("general.webroot") + "/admin"} icon={<TbSettings size={14} />} > <FormattedMessage id="navbar.avatar.admin" /> diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index 2271ac3..dcb70dd 100644 --- a/frontend/src/components/header/Header.tsx +++ b/frontend/src/components/header/Header.tsx @@ -125,7 +125,7 @@ const Header = () => { const authenticatedLinks: NavLink[] = [ { - link: config.get("general.appUrl") + "/upload", + link: config.get("general.webroot") + "/upload", label: t("navbar.upload"), }, { @@ -138,27 +138,27 @@ const Header = () => { let unauthenticatedLinks: NavLink[] = [ { - link: config.get("general.appUrl") + "/auth/signIn", + link: config.get("general.webroot") + "/auth/signIn", label: t("navbar.signin"), }, ]; if (config.get("share.allowUnauthenticatedShares")) { unauthenticatedLinks.unshift({ - link: config.get("general.appUrl") + "/upload", + link: config.get("general.webroot") + "/upload", label: t("navbar.upload"), }); } if (config.get("general.showHomePage")) unauthenticatedLinks.unshift({ - link: config.get("general.appUrl") + "/", + link: config.get("general.webroot") + "/", label: t("navbar.home"), }); if (config.get("share.allowRegistration")) unauthenticatedLinks.push({ - link: config.get("general.appUrl") + "/auth/signUp", + link: config.get("general.webroot") + "/auth/signUp", label: t("navbar.signup"), }); @@ -191,7 +191,7 @@ const Header = () => { return ( <MantineHeader height={HEADER_HEIGHT} mb={40} className={classes.root}> <Container className={classes.header}> - <Link href={config.get("general.appUrl")+"/"} passHref> + <Link href={config.get("general.webroot")+"/"} passHref> <Group> <Logo height={35} width={35} /> <Text weight={600}>{config.get("general.appName")}</Text> diff --git a/frontend/src/components/header/NavbarShareMenu.tsx b/frontend/src/components/header/NavbarShareMenu.tsx index 2ba8153..e54eab2 100644 --- a/frontend/src/components/header/NavbarShareMenu.tsx +++ b/frontend/src/components/header/NavbarShareMenu.tsx @@ -14,12 +14,12 @@ const NavbarShareMneu = () => { </ActionIcon> </Menu.Target> <Menu.Dropdown> - <Menu.Item component={Link} href={config.get("general.appUrl") + "/account/shares"} icon={<TbLink />}> + <Menu.Item component={Link} href={config.get("general.webroot") + "/account/shares"} icon={<TbLink />}> <FormattedMessage id="navbar.links.shares" /> </Menu.Item> <Menu.Item component={Link} - href={config.get("general.appUrl") + "/account/reverseShares"} + href={config.get("general.webroot") + "/account/reverseShares"} icon={<TbArrowLoopLeft />} > <FormattedMessage id="navbar.links.reverse" /> diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 43b8f1b..1fded5c 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -51,7 +51,7 @@ const FilePreview = ({ component={Link} onClick={() => modals.closeAll()} target="_blank" - href={`${config.get("general.appUrl")}/api/shares/${shareId}/files/${fileId}?download=false`} + href={`${config.get("general.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 ebd5cc8..8358ae0 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -54,7 +54,7 @@ const ErrorNotFound = () => { className={classes.description} ></Text> <Group position="center"> - <Button component={Link} href={config.get("general.appUrl") + "/"} variant="light"> + <Button component={Link} href={config.get("general.webroot") + "/"} variant="light"> <FormattedMessage id="404.button.home" /> </Button> </Group> diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index 7c0b3ea..bbe7582 100644 --- a/frontend/src/pages/account/shares.tsx +++ b/frontend/src/pages/account/shares.tsx @@ -58,7 +58,7 @@ const MyShares = () => { <FormattedMessage id="account.shares.description.empty" /> </Text> <Space h={5} /> - <Button component={Link} href={config.get("general.appUrl") + "/upload"} variant="light"> + <Button component={Link} href={config.get("general.webroot") + "/upload"} variant="light"> <FormattedMessage id="account.shares.button.create" /> </Button> </Stack> diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 79b3d6d..5e59ee6 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -45,10 +45,10 @@ const Intro = () => { <Text>Enough talked, have fun with Pingvin Share!</Text> <Text mt="lg">How to you want to continue?</Text> <Stack> - <Button href={config.get("general.appUrl") + "/admin/config/general"} component={Link}> + <Button href={config.get("general.webroot") + "/admin/config/general"} component={Link}> Customize configuration </Button> - <Button href={config.get("general.appUrl") + "/"} component={Link} variant="light"> + <Button href={config.get("general.webroot") + "/"} component={Link} variant="light"> Explore Pingvin Share </Button> </Stack> diff --git a/frontend/src/pages/auth/resetPassword/index.tsx b/frontend/src/pages/auth/resetPassword/index.tsx index 4062ca6..93753f9 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -95,7 +95,7 @@ const ResetPassword = () => { color="dimmed" size="sm" className={classes.control} - href={config.get("general.appUrl") + "/auth/signIn"} + href={config.get("general.webroot") + "/auth/signIn"} > <Center inline> <TbArrowLeft size={12} /> diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index d9e7c7c..d664b60 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -80,7 +80,7 @@ export default function Home() { useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace(config.get("general.appUrl") + "/upload"); + router.replace(config.get("general.webroot") + "/upload"); } }); }, []); @@ -144,7 +144,7 @@ export default function Home() { <Group mt={30}> <Button component={Link} - href={config.get("general.appUrl") + "/auth/signUp"} + href={config.get("general.webroot") + "/auth/signUp"} radius="xl" size="md" className={classes.control} From bff8c7716475aa5222aeb719f3ff4f0f1cb409a0 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Thu, 21 Mar 2024 23:01:18 +0000 Subject: [PATCH 05/14] use other config --- backend/prisma/seed/config.seed.ts | 5 +++++ frontend/next.config.js | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index 8216329..a6f4f7a 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -20,6 +20,11 @@ const configVariables: ConfigVariables = { defaultValue: "http://localhost:3000", secret: false, }, + webroot: { + type: "string", + defaultValue: "", + secret: false, + }, showHomePage: { type: "boolean", defaultValue: "true", diff --git a/frontend/next.config.js b/frontend/next.config.js index e3202d8..808c0d5 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -20,6 +20,5 @@ module.exports = withPWA({ }, serverRuntimeConfig: { apiURL: process.env.API_URL ?? 'http://localhost:8080', - webroot: process.env.WEBROOT ?? '', }, }); From 19cd21f50f54b1b4cb49ffa7062fa87da0601ac5 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 00:35:55 +0000 Subject: [PATCH 06/14] use environment instead --- backend/prisma/seed/config.seed.ts | 5 ----- .../admin/configuration/ConfigurationHeader.tsx | 4 +++- .../admin/configuration/ConfigurationNavBar.tsx | 6 ++++-- frontend/src/components/auth/SignInForm.tsx | 4 +++- frontend/src/components/header/ActionAvatar.tsx | 6 ++++-- frontend/src/components/header/Header.tsx | 13 +++++++------ frontend/src/components/header/NavbarShareMenu.tsx | 6 ++++-- frontend/src/components/share/FilePreview.tsx | 3 ++- frontend/src/pages/404.tsx | 4 +++- frontend/src/pages/account/shares.tsx | 4 +++- frontend/src/pages/admin/intro.tsx | 6 ++++-- frontend/src/pages/auth/resetPassword/index.tsx | 4 +++- frontend/src/pages/index.tsx | 6 ++++-- 13 files changed, 44 insertions(+), 27 deletions(-) diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index a6f4f7a..8216329 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 2b7b50d..057ac76 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 = ({ </Group> </Link> <MediaQuery smallerThan="sm" styles={{ display: "none" }}> - <Button variant="light" component={Link} href={config.get("general.webroot") + "/admin"}> + <Button variant="light" component={Link} href={webroot + "/admin"}> <FormattedMessage id="common.button.go-back" /> </Button> </MediaQuery> diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index 615ff09..f2bece5 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: <TbSquare /> }, { name: "Email", icon: <TbMail /> }, @@ -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()}`} > <Group> <ThemeIcon @@ -94,7 +96,7 @@ const ConfigurationNavBar = ({ </Stack> </Navbar.Section> <MediaQuery largerThan="sm" styles={{ display: "none" }}> - <Button mt="xl" variant="light" component={Link} href={config.get("general.webroot") + "/admin"}> + <Button mt="xl" variant="light" component={Link} href={webroot + "/admin"}> <FormattedMessage id="common.button.go-back" /> </Button> </MediaQuery> diff --git a/frontend/src/components/auth/SignInForm.tsx b/frontend/src/components/auth/SignInForm.tsx index ab24ca4..87aa826 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") && ( <Group position="right" mt="xs"> - <Anchor component={Link} href={config.get("general.webroot") + "/auth/resetPassword"} size="xs"> + <Anchor component={Link} href={webroot + "/auth/resetPassword"} size="xs"> <FormattedMessage id="resetPassword.title" /> </Anchor> </Group> diff --git a/frontend/src/components/header/ActionAvatar.tsx b/frontend/src/components/header/ActionAvatar.tsx index 3805cad..cf188ba 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 = () => { </ActionIcon> </Menu.Target> <Menu.Dropdown> - <Menu.Item component={Link} href={config.get("general.webroot") + "/account"} icon={<TbUser size={14} />}> + <Menu.Item component={Link} href={webroot + "/account"} icon={<TbUser size={14} />}> <FormattedMessage id="navbar.avatar.account" /> </Menu.Item> {user!.isAdmin && ( <Menu.Item component={Link} - href={config.get("general.webroot") + "/admin"} + href={webroot + "/admin"} icon={<TbSettings size={14} />} > <FormattedMessage id="navbar.avatar.admin" /> diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index dcb70dd..b6e801f 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 ( <MantineHeader height={HEADER_HEIGHT} mb={40} className={classes.root}> <Container className={classes.header}> - <Link href={config.get("general.webroot")+"/"} passHref> + <Link href={webroot + "/"} passHref> <Group> <Logo height={35} width={35} /> <Text weight={600}>{config.get("general.appName")}</Text> diff --git a/frontend/src/components/header/NavbarShareMenu.tsx b/frontend/src/components/header/NavbarShareMenu.tsx index e54eab2..9a70efe 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 = () => { </ActionIcon> </Menu.Target> <Menu.Dropdown> - <Menu.Item component={Link} href={config.get("general.webroot") + "/account/shares"} icon={<TbLink />}> + <Menu.Item component={Link} href={webroot + "/account/shares"} icon={<TbLink />}> <FormattedMessage id="navbar.links.shares" /> </Menu.Item> <Menu.Item component={Link} - href={config.get("general.webroot") + "/account/reverseShares"} + href={webroot + "/account/reverseShares"} icon={<TbArrowLoopLeft />} > <FormattedMessage id="navbar.links.reverse" /> diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 1fded5c..ee2af2e 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 8358ae0..6146172 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} ></Text> <Group position="center"> - <Button component={Link} href={config.get("general.webroot") + "/"} variant="light"> + <Button component={Link} href={webroot + "/"} variant="light"> <FormattedMessage id="404.button.home" /> </Button> </Group> diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index bbe7582..3013eca 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 = () => { <FormattedMessage id="account.shares.description.empty" /> </Text> <Space h={5} /> - <Button component={Link} href={config.get("general.webroot") + "/upload"} variant="light"> + <Button component={Link} href={webroot + "/upload"} variant="light"> <FormattedMessage id="account.shares.button.create" /> </Button> </Stack> diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 5e59ee6..29a8284 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 = () => { <Text>Enough talked, have fun with Pingvin Share!</Text> <Text mt="lg">How to you want to continue?</Text> <Stack> - <Button href={config.get("general.webroot") + "/admin/config/general"} component={Link}> + <Button href={webroot + "/admin/config/general"} component={Link}> Customize configuration </Button> - <Button href={config.get("general.webroot") + "/"} component={Link} variant="light"> + <Button href={webroot + "/"} component={Link} variant="light"> Explore Pingvin Share </Button> </Stack> diff --git a/frontend/src/pages/auth/resetPassword/index.tsx b/frontend/src/pages/auth/resetPassword/index.tsx index 93753f9..c7d938e 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"} > <Center inline> <TbArrowLeft size={12} /> diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index d664b60..28d64ae 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() { <Group mt={30}> <Button component={Link} - href={config.get("general.webroot") + "/auth/signUp"} + href={webroot + "/auth/signUp"} radius="xl" size="md" className={classes.control} From 0e2a963e817c216e01ecf40099630f9bdac33e04 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 00:18:27 +0000 Subject: [PATCH 07/14] webroot in logo --- frontend/src/components/Logo.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Logo.tsx b/frontend/src/components/Logo.tsx index 44fe2e4..5473af8 100644 --- a/frontend/src/components/Logo.tsx +++ b/frontend/src/components/Logo.tsx @@ -1,4 +1,5 @@ const Logo = ({ height, width }: { height: number; width: number }) => { - return <img src="/img/logo.png" alt="logo" height={height} width={width} />; + const webroot = process.env.WEBROOT || ""; + return <img src={webroot + "/img/logo.png"} alt="logo" height={height} width={width} />; }; export default Logo; From 5b7d99f9d68372bb0334c01c8e8703ece65b5870 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 00:24:32 +0000 Subject: [PATCH 08/14] removed unused; --- frontend/src/pages/404.tsx | 1 - frontend/src/pages/admin/intro.tsx | 1 - frontend/src/pages/auth/resetPassword/index.tsx | 1 - frontend/src/pages/index.tsx | 1 - 4 files changed, 4 deletions(-) diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index 6146172..df10c1a 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -41,7 +41,6 @@ const useStyles = createStyles((theme) => ({ const ErrorNotFound = () => { const { classes } = useStyles(); - const config = useConfig(); return ( <> <Meta title="Not found" /> diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 29a8284..2c71c07 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -15,7 +15,6 @@ import useConfig from "../../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; const Intro = () => { - const config = useConfig(); return ( <> <Meta title="Intro" /> diff --git a/frontend/src/pages/auth/resetPassword/index.tsx b/frontend/src/pages/auth/resetPassword/index.tsx index c7d938e..21f4bf2 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -64,7 +64,6 @@ const ResetPassword = () => { ), }); - const config = useConfig(); return ( <Container size={460} my={30}> <Title order={2} weight={900} align="center"> diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 28d64ae..f0482d2 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -76,7 +76,6 @@ export default function Home() { const { classes } = useStyles(); const { refreshUser } = useUser(); const router = useRouter(); - const config = useConfig(); // If the user is already logged in, redirect to the upload page useEffect(() => { From ab9d6f6b4444bbea0c16160b81454c23d50e598d Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 00:41:14 +0000 Subject: [PATCH 09/14] more cleanups --- .../src/components/admin/configuration/ConfigurationNavBar.tsx | 2 -- frontend/src/components/header/ActionAvatar.tsx | 2 -- frontend/src/components/header/NavbarShareMenu.tsx | 2 -- frontend/src/components/share/FilePreview.tsx | 2 -- frontend/src/pages/404.tsx | 1 - frontend/src/pages/admin/intro.tsx | 1 - frontend/src/pages/auth/resetPassword/index.tsx | 1 - frontend/src/pages/index.tsx | 1 - 8 files changed, 12 deletions(-) diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index f2bece5..060d513 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -13,7 +13,6 @@ import Link from "next/link"; import { Dispatch, SetStateAction } from "react"; 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 || ""; @@ -49,7 +48,6 @@ const ConfigurationNavBar = ({ setIsMobileNavBarOpened: Dispatch<SetStateAction<boolean>>; }) => { const { classes } = useStyles(); - const config = useConfig(); return ( <Navbar p="md" diff --git a/frontend/src/components/header/ActionAvatar.tsx b/frontend/src/components/header/ActionAvatar.tsx index cf188ba..729a9ba 100644 --- a/frontend/src/components/header/ActionAvatar.tsx +++ b/frontend/src/components/header/ActionAvatar.tsx @@ -4,13 +4,11 @@ import { TbDoorExit, TbSettings, TbUser } from "react-icons/tb"; import useUser from "../../hooks/user.hook"; 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(); return ( <Menu position="bottom-start" withinPortal> diff --git a/frontend/src/components/header/NavbarShareMenu.tsx b/frontend/src/components/header/NavbarShareMenu.tsx index 9a70efe..b29d7e5 100644 --- a/frontend/src/components/header/NavbarShareMenu.tsx +++ b/frontend/src/components/header/NavbarShareMenu.tsx @@ -2,12 +2,10 @@ import { ActionIcon, Menu } from "@mantine/core"; import Link from "next/link"; 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 ( <Menu position="bottom-start" withinPortal> <Menu.Target> diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index ee2af2e..a27cef6 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -12,7 +12,6 @@ import React, { Dispatch, SetStateAction, useEffect, useState } from "react"; import { FormattedMessage } from "react-intl"; import api from "../../services/api.service"; import Markdown from "markdown-to-jsx"; -import useConfig from "../../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; @@ -38,7 +37,6 @@ const FilePreview = ({ mimeType: string; }) => { const [isNotSupported, setIsNotSupported] = useState(false); - const config = useConfig(); if (isNotSupported) return <UnSupportedFile />; return ( <Stack> diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index df10c1a..65af037 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -9,7 +9,6 @@ import { import Link from "next/link"; import Meta from "../components/Meta"; import { FormattedMessage } from "react-intl"; -import useConfig from "../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 2c71c07..4554fdf 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -10,7 +10,6 @@ import { import Link from "next/link"; import Logo from "../../components/Logo"; import Meta from "../../components/Meta"; -import useConfig from "../../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; diff --git a/frontend/src/pages/auth/resetPassword/index.tsx b/frontend/src/pages/auth/resetPassword/index.tsx index 21f4bf2..e61ffda 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -20,7 +20,6 @@ import * as yup from "yup"; import useTranslate from "../../../hooks/useTranslate.hook"; import authService from "../../../services/auth.service"; import toast from "../../../utils/toast.util"; -import useConfig from "../../../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index f0482d2..64e74c2 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -16,7 +16,6 @@ import { FormattedMessage } from "react-intl"; import Logo from "../components/Logo"; import Meta from "../components/Meta"; import useUser from "../hooks/user.hook"; -import useConfig from "../hooks/config.hook"; const webroot = process.env.WEBROOT || ""; From 917e6ef820d65163b0e0d7ab4113edcde09ca9ab Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 11:17:32 +0000 Subject: [PATCH 10/14] whitespace diff; --- frontend/src/components/share/FilePreview.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index a27cef6..55b37de 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -38,6 +38,7 @@ const FilePreview = ({ }) => { const [isNotSupported, setIsNotSupported] = useState(false); if (isNotSupported) return <UnSupportedFile />; + return ( <Stack> <FilePreviewContext.Provider From 7d4fc04addd764e18805253ae551ed8c2d6444ac Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 11:18:18 +0000 Subject: [PATCH 11/14] whitespace diff; --- frontend/src/pages/404.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index 65af037..5c0aa54 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -40,6 +40,7 @@ const useStyles = createStyles((theme) => ({ const ErrorNotFound = () => { const { classes } = useStyles(); + return ( <> <Meta title="Not found" /> From bcf329ff674ffda63525eb33f572244e4ac1c0c5 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 11:38:58 +0000 Subject: [PATCH 12/14] also router.redirect --- frontend/src/components/auth/SignUpForm.tsx | 6 ++++-- frontend/src/pages/auth/signIn.tsx | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/auth/SignUpForm.tsx b/frontend/src/components/auth/SignUpForm.tsx index 50a9f97..71f7d9c 100644 --- a/frontend/src/components/auth/SignUpForm.tsx +++ b/frontend/src/components/auth/SignUpForm.tsx @@ -19,6 +19,8 @@ import useUser from "../../hooks/user.hook"; import authService from "../../services/auth.service"; import toast from "../../utils/toast.util"; +const webroot = process.env.WEBROOT || ""; + const SignUpForm = () => { const config = useConfig(); const router = useRouter(); @@ -52,9 +54,9 @@ const SignUpForm = () => { .then(async () => { const user = await refreshUser(); if (user?.isAdmin) { - router.replace("/admin/intro"); + router.replace(webroot + "/admin/intro"); } else { - router.replace("/upload"); + router.replace(webroot + "/upload"); } }) .catch(toast.axiosError); diff --git a/frontend/src/pages/auth/signIn.tsx b/frontend/src/pages/auth/signIn.tsx index c30ec11..faafb81 100644 --- a/frontend/src/pages/auth/signIn.tsx +++ b/frontend/src/pages/auth/signIn.tsx @@ -7,6 +7,8 @@ import Meta from "../../components/Meta"; import useUser from "../../hooks/user.hook"; import useTranslate from "../../hooks/useTranslate.hook"; +const webroot = process.env.WEBROOT || ""; + export function getServerSideProps(context: GetServerSidePropsContext) { return { props: { redirectPath: context.query.redirect ?? null }, @@ -25,7 +27,7 @@ const SignIn = ({ redirectPath }: { redirectPath?: string }) => { useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace(redirectPath ?? "/upload"); + router.replace(redirectPath ?? webroot + "/upload"); } else { setIsLoading(false); } From 1335b3f6bcd55fbcac0529f39268ff3fb74908b6 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 15:55:54 +0000 Subject: [PATCH 13/14] basepath --- frontend/next.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/next.config.js b/frontend/next.config.js index 808c0d5..9a7ebb3 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -21,4 +21,5 @@ module.exports = withPWA({ serverRuntimeConfig: { apiURL: process.env.API_URL ?? 'http://localhost:8080', }, + basePath: process.env.WEBROOT ?? '', }); From 91987eb8134518838cba0731e828f0814a322551 Mon Sep 17 00:00:00 2001 From: gluzzati <gluzzati@camtouch3d.com> Date: Fri, 22 Mar 2024 16:49:03 +0000 Subject: [PATCH 14/14] pass env in pathPrefix --- frontend/next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/next.config.js b/frontend/next.config.js index 9a7ebb3..de76538 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -12,6 +12,7 @@ const withPWA = require("next-pwa")({ }, ], reloadOnOnline: false, + pathPrefix: '/pengvin-share', }); module.exports = withPWA({ @@ -21,5 +22,4 @@ module.exports = withPWA({ serverRuntimeConfig: { apiURL: process.env.API_URL ?? 'http://localhost:8080', }, - basePath: process.env.WEBROOT ?? '', });