Skip to content

Commit 2aa4aff

Browse files
authored
Fix build and lint failures on dev (#1445)
1 parent 6e769c3 commit 2aa4aff

6 files changed

Lines changed: 28 additions & 19 deletions

File tree

apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/actions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"use server";
22
import { isRemoteDevelopmentEnvironmentEnabled } from "@/lib/remote-development-environment/env";
33

4-
async function getStackServerApp() {
4+
async function getServerApp() {
55
if (isRemoteDevelopmentEnvironmentEnabled()) {
66
throw new Error("Team invitation management is not available in the remote development environment dashboard.");
77
}
8-
return (await import("@/stack/server")).stackServerApp;
8+
return (await import("@/stack/server")).getStackServerApp();
99
}
1010

1111
export async function revokeInvitation(teamId: string, invitationId: string) {
1212
"use server";
13-
const stackServerApp = await getStackServerApp();
13+
const stackServerApp = await getServerApp();
1414
const user = await stackServerApp.getUser();
1515
const team = await user?.getTeam(teamId);
1616
if (!team) {
@@ -24,7 +24,7 @@ export async function revokeInvitation(teamId: string, invitationId: string) {
2424
}
2525

2626
export async function listInvitations(teamId: string) {
27-
const stackServerApp = await getStackServerApp();
27+
const stackServerApp = await getServerApp();
2828
const user = await stackServerApp.getUser();
2929
const team = await user?.getTeam(teamId);
3030
if (!team) {
@@ -39,7 +39,7 @@ export async function listInvitations(teamId: string) {
3939
}
4040

4141
export async function inviteUser(teamId: string, email: string, origin: string) {
42-
const stackServerApp = await getStackServerApp();
42+
const stackServerApp = await getServerApp();
4343
const callbackUrl = new URL(stackServerApp.urls.teamInvitation, origin).toString();
4444
const user = await stackServerApp.getUser();
4545
const team = await user?.getTeam(teamId);

apps/dashboard/src/app/(main)/integrations/featurebase/sso/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stackServerApp } from "@/stack/server";
1+
import { getStackServerApp } from "@/stack/server";
22
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
33
import { getOrCreateFeaturebaseUser } from "@stackframe/stack-shared/dist/utils/featurebase";
44
import { urlString } from "@stackframe/stack-shared/dist/utils/urls";
@@ -21,7 +21,7 @@ export default async function FeaturebaseSSO({
2121
return <div>Missing return_to parameter. Please go back and try again.</div>;
2222
}
2323

24-
const user = await stackServerApp.getUser();
24+
const user = await getStackServerApp().getUser();
2525
if (!user) {
2626
redirect(urlString`/handler/sign-in?after_auth_return_to=${urlString`/integrations/featurebase/sso?return_to=${returnTo}`}`);
2727
}

apps/dashboard/src/app/(main)/integrations/oauth-confirm-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stackServerApp } from "@/stack/server";
1+
import { getStackServerApp } from "@/stack/server";
22
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
33
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
44
import { redirect } from "next/navigation";
@@ -18,7 +18,7 @@ export default async function IntegrationConfirmPage(props: {
1818
const onContinue = async (options: { projectId: string, projectName?: string }) => {
1919
"use server";
2020

21-
const user = await stackServerApp.getUser();
21+
const user = await getStackServerApp().getUser();
2222
if (!user) {
2323
return { error: "unauthorized" };
2424
}

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

apps/dashboard/src/stack/server.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ import { StackServerApp } from "@stackframe/stack";
55
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
66
import { stackClientApp } from "./client";
77

8-
if (isRemoteDevelopmentEnvironmentEnabled()) {
9-
throw new StackAssertionError("stackServerApp is not available in the local remote development environment dashboard.");
10-
}
8+
type InternalServerApp = StackServerApp<true, "internal">;
9+
let _stackServerApp: InternalServerApp | undefined;
1110

12-
export const stackServerApp = new StackServerApp({
13-
inheritsFrom: stackClientApp,
14-
});
11+
export function getStackServerApp(): InternalServerApp {
12+
if (!_stackServerApp) {
13+
if (isRemoteDevelopmentEnvironmentEnabled()) {
14+
throw new StackAssertionError("stackServerApp is not available in the local remote development environment dashboard.");
15+
}
16+
_stackServerApp = new StackServerApp({
17+
inheritsFrom: stackClientApp,
18+
});
19+
}
20+
return _stackServerApp;
21+
}

packages/stack-cli/src/commands/whoami.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function registerWhoamiCommand(program: Command) {
88
.description("Show the currently logged-in Stack Auth CLI user")
99
.action(async () => {
1010
const flags = program.opts();
11-
const auth = resolveSessionAuth(flags);
11+
const auth = resolveSessionAuth();
1212
const user = await getInternalUser(auth);
1313
const teams = await user.listTeams();
1414

0 commit comments

Comments
 (0)