Skip to content

Commit 20d0c1f

Browse files
Fix dashboard build without env: handle missing NEXT_PUBLIC_STACK_API_URL gracefully
Instead of requiring .env.production.local in CI workflows, make layout.tsx handle the case where NEXT_PUBLIC_STACK_API_URL is unset by conditionally setting metadataBase and OG images. This reverts the workflow changes from the previous commit. Co-Authored-By: Konstantin Wohlwend <n2d4xc@gmail.com>
1 parent 085434d commit 20d0c1f

4 files changed

Lines changed: 5 additions & 12 deletions

File tree

.github/workflows/check-prisma-migrations.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
wait-for: 3s
4343
log-output-if: true
4444

45-
- name: Create .env.production.local file for apps/dashboard
46-
run: cp apps/dashboard/.env.development apps/dashboard/.env.production.local
47-
4845
- name: Install dependencies
4946
run: pnpm install --frozen-lockfile
5047

.github/workflows/setup-tests-with-custom-base-port.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ jobs:
3737
- name: Install packages
3838
run: pnpm install
3939

40-
- name: Create .env.production.local file for apps/dashboard
41-
run: cp apps/dashboard/.env.development apps/dashboard/.env.production.local
42-
4340
- run: pnpm run build:packages
4441
- run: pnpm run codegen
4542
- run: pnpm run start-deps

.github/workflows/setup-tests.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
- name: Install packages
3636
run: pnpm install
3737

38-
- name: Create .env.production.local file for apps/dashboard
39-
run: cp apps/dashboard/.env.development apps/dashboard/.env.production.local
40-
4138
- run: pnpm run build:packages
4239
- run: pnpm run codegen
4340
- run: pnpm run start-deps

apps/dashboard/src/app/layout.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import '../polyfills';
1313
import './globals.css';
1414
import { LayoutClient } from './layout-client';
1515

16+
const apiUrl = getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL');
17+
1618
export const metadata: Metadata = {
17-
metadataBase: new URL(getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL') || ''),
19+
...apiUrl ? { metadataBase: new URL(apiUrl) } : {},
1820
title: {
1921
default: 'Stack Auth Dashboard',
2022
template: '%s | Stack Auth',
@@ -23,12 +25,12 @@ export const metadata: Metadata = {
2325
openGraph: {
2426
title: 'Stack Auth Dashboard',
2527
description: 'Stack Auth is the open-source Auth0 alternative, and the fastest way to add authentication to your web app.',
26-
images: [`${getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL')}/open-graph-image.png`]
28+
...apiUrl ? { images: [`${apiUrl}/open-graph-image.png`] } : {},
2729
},
2830
twitter: {
2931
title: 'Stack Auth Dashboard',
3032
description: 'Stack Auth is the open-source Auth0 alternative, and the fastest way to add authentication to your web app.',
31-
images: [`${getPublicEnvVar('NEXT_PUBLIC_STACK_API_URL')}/open-graph-image.png`]
33+
...apiUrl ? { images: [`${apiUrl}/open-graph-image.png`] } : {},
3234
},
3335
};
3436

0 commit comments

Comments
 (0)