diff --git a/.env.example b/.env.example index dc2a08a..f0707f5 100644 --- a/.env.example +++ b/.env.example @@ -22,3 +22,10 @@ AUTH_DISCORD_SECRET="" # Prisma # https://www.prisma.io/docs/reference/database-reference/connection-urls#env DATABASE_URL="mysql://root:password@localhost:3306/file-hosting" + + +# Next Auth OAUTH Redirect URL +NEXTAUTH_URL="" + +# Page base URL +NEXT_PUBLIC_PAGE_URL="" \ No newline at end of file diff --git a/src/app/_components/FileGrid.tsx b/src/app/_components/FileGrid.tsx index 50e7c21..892d032 100644 --- a/src/app/_components/FileGrid.tsx +++ b/src/app/_components/FileGrid.tsx @@ -7,7 +7,6 @@ import { useEffect, useState } from "react"; import toast from "react-hot-toast"; import { useRouter } from "next/navigation"; import { env } from "~/env.js"; - interface File { id: string; name: string; @@ -22,6 +21,7 @@ export default function FileGrid({ session }: FileGridProps) { const [files, setFiles] = useState([]); const [error, setError] = useState(null); const router = useRouter(); + const pageUrl = env.NEXT_PUBLIC_PAGE_URL; // Assuming PAGE_URL is defined in your environment variables const fetchFiles = async () => { try { @@ -98,7 +98,7 @@ export default function FileGrid({ session }: FileGridProps) { const handleCopyUrl = (url: string) => { navigator.clipboard - .writeText(env.PAGE_URL + url) + .writeText(pageUrl + url) .then(() => toast.success("File URL copied to clipboard!")) .catch(() => toast.error("Failed to copy URL.")); }; @@ -137,7 +137,7 @@ export default function FileGrid({ session }: FileGridProps) { className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20" > -
diff --git a/src/env.js b/src/env.js index e95a84e..fb339f6 100644 --- a/src/env.js +++ b/src/env.js @@ -19,7 +19,7 @@ export const env = createEnv({ NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), - PAGE_URL: z.string().url(), + }, /** @@ -29,6 +29,7 @@ export const env = createEnv({ */ client: { // NEXT_PUBLIC_CLIENTVAR: z.string(), + NEXT_PUBLIC_PAGE_URL: z.string().url(), }, /** @@ -41,7 +42,7 @@ export const env = createEnv({ AUTH_DISCORD_SECRET: process.env.AUTH_DISCORD_SECRET, DATABASE_URL: process.env.DATABASE_URL, NODE_ENV: process.env.NODE_ENV, - PAGE_URL: process.env.PAGE_URL, + NEXT_PUBLIC_PAGE_URL: process.env.NEXT_PUBLIC_PAGE_URL, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially