Skip to content

Commit

Permalink
Add BASE_PATH env variable
Browse files Browse the repository at this point in the history
Importing logo file directly. Adding environment variable to `Image` src doesn't seem to work.
Linking to background image using path.  Mantine `BackgroundImage` doesn't support directly importing file.
  • Loading branch information
otobot1 committed Oct 25, 2023
1 parent 8f9668f commit bfc62d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# next.js base path
# https://nextjs.org/docs/app/api-reference/next-config-js/basePath
BASE_PATH="/"

# Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
# DATABASE_URL="mysql://root@localhost:9999/modslist?schema=public"
Expand All @@ -23,7 +27,8 @@ SEED_RANDOM_DATA="false"
# https://next-auth.js.org/configuration/options#secret
# For local development, you can just keyboard-smash a longish string as your secret
NEXTAUTH_SECRET=""
NEXTAUTH_URL="http://localhost:3000"
# URL for NextAuth's Auth endpoint. Must be full path.
NEXTAUTH_URL="http://localhost:3000/auth"

# Next Auth Discord Provider
DISCORD_CLIENT_ID=""
Expand Down
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/** @type {import("next").NextConfig} */
const config = {
basePath: process.env.BASE_PATH,
reactStrictMode: true,
images: { //TODO!: figure out how to fix crash on next.config.mjs change
remotePatterns: [
Expand Down
5 changes: 3 additions & 2 deletions src/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Flex, createStyles, Title, Box } from "@mantine/core";
import Image from "next/image";
import cmlLogo from "~/../public/images/logo/cml_logo.png";



Expand Down Expand Up @@ -33,13 +34,13 @@ export const Header = () => {
<Flex className={classes.header}>
<Image
priority
src="/images/logo/cml_logo.png"
src={cmlLogo}
height={height}
width={width}
alt="CML Logo"
/>
<Title className={classes.siteTitle} order={1}>Celeste Mods List</Title>
<Box w={width}/>
<Box w={width} />
</Flex>
</header>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const Layout = ({
/>
</Head>
<BackgroundImage
src="/images/cml_background1.png"
src={`${process.env.BASE_PATH}/images/cml_background1.png`}
className={classes.backgroundImage}
>
<Grid gutter="0">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const MyApp: AppType<{ session: Session | null; }> = ({
pageProps: { session, ...pageProps },
}) => {
return (
<SessionProvider session={session}>
<SessionProvider session={session} basePath={process.env.BASE_PATH}>
<MantineProvider
emotionCache={emotionCache}
withGlobalStyles
Expand Down

0 comments on commit bfc62d3

Please sign in to comment.