@@ -4,6 +4,7 @@ import { defineStack } from '@objectstack/spec';
44import { AppPlugin , DriverPlugin } from '@objectstack/runtime' ;
55import { ObjectQLPlugin } from '@objectstack/objectql' ;
66import { InMemoryDriver } from '@objectstack/driver-memory' ;
7+ import { AuthPlugin } from '@objectstack/plugin-auth' ;
78import CrmApp from '../app-crm/objectstack.config' ;
89import TodoApp from '../app-todo/objectstack.config' ;
910import BiPluginManifest from '../plugin-bi/objectstack.config' ;
@@ -12,6 +13,15 @@ import BiPluginManifest from '../plugin-bi/objectstack.config';
1213// This project acts as a "Platform Server" that loads multiple apps and plugins.
1314// It effectively replaces the manual composition in `src/index.ts`.
1415
16+ // Shared authentication plugin — reads secrets from environment variables so the
17+ // same config works both locally and on Vercel (where VERCEL_URL is injected).
18+ const authPlugin = new AuthPlugin ( {
19+ secret : process . env . AUTH_SECRET ?? 'dev-secret-please-change-in-production-min-32-chars' ,
20+ baseUrl : process . env . NEXT_PUBLIC_BASE_URL ?? ( process . env . VERCEL_URL
21+ ? `https://${ process . env . VERCEL_URL } `
22+ : 'http://localhost:3000' ) ,
23+ } ) ;
24+
1525export default defineStack ( {
1626 manifest : {
1727 id : 'app-host' ,
@@ -27,6 +37,8 @@ export default defineStack({
2737 new ObjectQLPlugin ( ) ,
2838 // Register Default Driver (Memory)
2939 new DriverPlugin ( new InMemoryDriver ( ) ) ,
40+ // Authentication — required for production (Vercel) deployments
41+ authPlugin ,
3042 // Wrap Manifests/Stacks in AppPlugin adapter
3143 new AppPlugin ( CrmApp ) ,
3244 new AppPlugin ( TodoApp ) ,
@@ -90,6 +102,7 @@ export const PreviewHostExample = defineStack({
90102 plugins : [
91103 new ObjectQLPlugin ( ) ,
92104 new DriverPlugin ( new InMemoryDriver ( ) ) ,
105+ authPlugin ,
93106 new AppPlugin ( CrmApp ) ,
94107 new AppPlugin ( TodoApp ) ,
95108 new AppPlugin ( BiPluginManifest )
0 commit comments