diff --git a/frontend/src/app/[id]/page.tsx b/frontend/src/app/[id]/page.tsx index a3af022..a69886e 100644 --- a/frontend/src/app/[id]/page.tsx +++ b/frontend/src/app/[id]/page.tsx @@ -12,6 +12,7 @@ import { makeClass, relativeTimeFormat } from '/src/utils' import EventAvailabilities from './EventAvailabilities' import styles from './page.module.scss' +import appLink from '/src/utils/appLink' interface PageProps { params: { id: string } @@ -49,10 +50,10 @@ const Page = async ({ params }: PageProps) => { >{t('common:created', { date: relativeTimeFormat(Temporal.Instant.fromEpochSeconds(event.created_at), i18n.language) })} - {`https://crab.fit/${event.id}`} + {appLink(event.id)}

- ___ + ___

diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 83a99c0..9508ba2 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -8,11 +8,12 @@ import { fallbackLng } from '/src/i18n/options' import { useTranslation } from '/src/i18n/server' import './global.css' +import appLink from '../utils/appLink' const karla = Karla({ subsets: ['latin'] }) export const metadata: Metadata = { - metadataBase: new URL('https://crab.fit'), + metadataBase: new URL(appLink('')), title: { absolute: 'Crab Fit', template: '%s - Crab Fit', diff --git a/frontend/src/components/CreateForm/components/EventInfo/EventInfo.tsx b/frontend/src/components/CreateForm/components/EventInfo/EventInfo.tsx index 4376001..0fcf349 100644 --- a/frontend/src/components/CreateForm/components/EventInfo/EventInfo.tsx +++ b/frontend/src/components/CreateForm/components/EventInfo/EventInfo.tsx @@ -5,6 +5,7 @@ import { EventResponse } from '/src/config/api' import { useTranslation } from '/src/i18n/client' import styles from './EventInfo.module.scss' +import appLink from '/src/utils/appLink' interface EventInfoProps { event: EventResponse @@ -16,10 +17,10 @@ const EventInfo = ({ event }: EventInfoProps) => { return

{event.name}

- {`https://crab.fit/${event.id}`} + {appLink(event.id)}

- ___ + ___

} diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index cb848a7..eb8c00c 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -6,6 +6,7 @@ import logo from '/src/res/logo.svg' import { makeClass } from '/src/utils' import styles from './Header.module.scss' +import appLink from '/src/utils/appLink' const samuraiBob = localFont({ src: './samuraibob.woff2', @@ -37,6 +38,7 @@ const Header = async ({ isFull, isSmall }: HeaderProps) => { {t('common:tagline')} } +

{appLink('test')}

} diff --git a/frontend/src/utils/appLink.tsx b/frontend/src/utils/appLink.tsx new file mode 100644 index 0000000..9a1bcdc --- /dev/null +++ b/frontend/src/utils/appLink.tsx @@ -0,0 +1,7 @@ +export default function appLink(path: string) { + const proto = process?.env?.NODE_ENV === 'production' ? 'https' : 'http' + const host = + process?.env?.NEXT_PUBLIC_HOSTNAME ?? + (process?.env?.NODE_ENV === 'production' ? 'crab.fit' : 'localhost:3000') + return `${proto}://${host}/${path}` +}