diff --git a/frontend/next.config.js b/frontend/next.config.js index 808c0d5..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({ 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 logo; + const webroot = process.env.WEBROOT || ""; + return logo; }; export default Logo; diff --git a/frontend/src/components/admin/configuration/ConfigurationHeader.tsx b/frontend/src/components/admin/configuration/ConfigurationHeader.tsx index a78dce1..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 = ({ - diff --git a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx index 9df1a19..060d513 100644 --- a/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx +++ b/frontend/src/components/admin/configuration/ConfigurationNavBar.tsx @@ -14,6 +14,8 @@ import { Dispatch, SetStateAction } from "react"; import { TbAt, TbMail, TbShare, TbSocial, TbSquare } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; +const webroot = process.env.WEBROOT || ""; + const categories = [ { name: "General", icon: }, { name: "Email", icon: }, @@ -69,7 +71,7 @@ const ConfigurationNavBar = ({ : undefined } key={category.name} - href={`/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 e5bd96b..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") && ( - + 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/components/header/ActionAvatar.tsx b/frontend/src/components/header/ActionAvatar.tsx index 414c5a0..729a9ba 100644 --- a/frontend/src/components/header/ActionAvatar.tsx +++ b/frontend/src/components/header/ActionAvatar.tsx @@ -5,6 +5,8 @@ import useUser from "../../hooks/user.hook"; import authService from "../../services/auth.service"; import { FormattedMessage, useIntl } from "react-intl"; +const webroot = process.env.WEBROOT || ""; + const ActionAvatar = () => { const { user } = useUser(); @@ -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..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: "/upload", + link: webroot + "/upload", label: t("navbar.upload"), }, { @@ -138,27 +139,27 @@ const Header = () => { let unauthenticatedLinks: NavLink[] = [ { - link: "/auth/signIn", + link: webroot + "/auth/signIn", label: t("navbar.signin"), }, ]; if (config.get("share.allowUnauthenticatedShares")) { unauthenticatedLinks.unshift({ - link: "/upload", + link: webroot + "/upload", label: t("navbar.upload"), }); } if (config.get("general.showHomePage")) unauthenticatedLinks.unshift({ - link: "/", + link: webroot + "/", label: t("navbar.home"), }); if (config.get("share.allowRegistration")) unauthenticatedLinks.push({ - link: "/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 56775dc..b29d7e5 100644 --- a/frontend/src/components/header/NavbarShareMenu.tsx +++ b/frontend/src/components/header/NavbarShareMenu.tsx @@ -3,6 +3,8 @@ import Link from "next/link"; import { TbArrowLoopLeft, TbLink } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; +const webroot = process.env.WEBROOT || ""; + const NavbarShareMneu = () => { 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..55b37de 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -13,6 +13,8 @@ import { FormattedMessage } from "react-intl"; import api from "../../services/api.service"; import Markdown from "markdown-to-jsx"; +const webroot = process.env.WEBROOT || ""; + const FilePreviewContext = React.createContext<{ shareId: string; fileId: string; @@ -49,7 +51,7 @@ const FilePreview = ({ component={Link} onClick={() => modals.closeAll()} target="_blank" - href={`/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 99a50aa..5c0aa54 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -10,6 +10,8 @@ import Link from "next/link"; import Meta from "../components/Meta"; import { FormattedMessage } from "react-intl"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ root: { paddingTop: 80, @@ -53,7 +55,7 @@ const ErrorNotFound = () => { className={classes.description} > - diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index 9edb228..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 = () => { - diff --git a/frontend/src/pages/admin/intro.tsx b/frontend/src/pages/admin/intro.tsx index 59833fd..4554fdf 100644 --- a/frontend/src/pages/admin/intro.tsx +++ b/frontend/src/pages/admin/intro.tsx @@ -11,6 +11,8 @@ import Link from "next/link"; import Logo from "../../components/Logo"; import Meta from "../../components/Meta"; +const webroot = process.env.WEBROOT || ""; + const Intro = () => { 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..e61ffda 100644 --- a/frontend/src/pages/auth/resetPassword/index.tsx +++ b/frontend/src/pages/auth/resetPassword/index.tsx @@ -21,6 +21,8 @@ import useTranslate from "../../../hooks/useTranslate.hook"; import authService from "../../../services/auth.service"; import toast from "../../../utils/toast.util"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ title: { fontSize: 26, @@ -93,7 +95,7 @@ const ResetPassword = () => { color="dimmed" size="sm" className={classes.control} - href={"/auth/signIn"} + href={webroot + "/auth/signIn"} >
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); } diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 227fad7..64e74c2 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -17,6 +17,8 @@ import Logo from "../components/Logo"; import Meta from "../components/Meta"; import useUser from "../hooks/user.hook"; +const webroot = process.env.WEBROOT || ""; + const useStyles = createStyles((theme) => ({ inner: { display: "flex", @@ -78,7 +80,7 @@ export default function Home() { useEffect(() => { refreshUser().then((user) => { if (user) { - router.replace("/upload"); + router.replace(webroot + "/upload"); } }); }, []); @@ -142,7 +144,7 @@ export default function Home() {