diff --git a/.env.example b/.env.example index a2b6290..6dfce18 100644 --- a/.env.example +++ b/.env.example @@ -9,4 +9,7 @@ VITE_PROXY_URL=https://localhost:3000 VITE_API_URL=https://localhost:3001 # Advanced -VITE_S3_PREFIX=https://s3.eu-west-3.amazonaws.com/meeting-baas-video \ No newline at end of file +VITE_S3_PREFIX=https://s3.eu-west-3.amazonaws.com/meeting-baas-video + +# Environment +NODE_ENV=development \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3f310b2..d2c2f21 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ web_modules/ .env.development.local .env.test.local .env.production.local +.env.pre-production.local .env.local # parcel-bundler cache (https://parceljs.org/) diff --git a/apps/api/.env.example b/apps/api/.env.example index 7e2a5b1..bf998c7 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -14,11 +14,9 @@ TURSO_AUTH_TOKEN="" # Auth BETTER_AUTH_SECRET="" BETTER_AUTH_URL="http://localhost:3001" -BETTER_AUTH_TRUSTED_ORIGINS="http://localhost:5173" -# Keyless Config -# This section is a work-in-progress +# CORS +API_TRUSTED_ORIGINS="http://localhost:5173" -# Hono Firebase Compatability -# https://github.com/honojs/hono/issues/1695 -# NODEJS_HELPERS="0" \ No newline at end of file +# Environment +NODE_ENV=development \ No newline at end of file diff --git a/apps/api/.firebaserc b/apps/api/.firebaserc deleted file mode 100644 index a851630..0000000 --- a/apps/api/.firebaserc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "projects": { - "transcript-seeker": "transcript-seeker-bdc29" - }, - "targets": { - "transcript-seeker-api-c8419": [ - "transcript-seeker-api-c8419" - ] - }, - "etags": {} -} diff --git a/apps/api/package.json b/apps/api/package.json index 325951f..415c270 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -20,7 +20,7 @@ "dependencies": { "@hono/node-server": "^1.13.2", "@libsql/client": "^0.14.0", - "better-auth": "0.7.1-beta.6", + "better-auth": "0.7.2", "dotenv": "^16.4.5", "drizzle-orm": "^0.35.2", "firebase-admin": "^12.6.0", diff --git a/apps/api/src/lib/auth.ts b/apps/api/src/lib/auth.ts index c381d5e..056fc35 100644 --- a/apps/api/src/lib/auth.ts +++ b/apps/api/src/lib/auth.ts @@ -9,6 +9,7 @@ export const auth = betterAuth({ logger: { verboseLogging: true, }, + trustedOrigins: process.env.API_TRUSTED_ORIGINS?.split(','), socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, diff --git a/apps/api/src/routes/auth.ts b/apps/api/src/routes/auth.ts index 5274c65..ce69056 100644 --- a/apps/api/src/routes/auth.ts +++ b/apps/api/src/routes/auth.ts @@ -8,7 +8,7 @@ const authRouter = new Hono(); authRouter.use( '/**', cors({ - origin: process.env.BETTER_AUTH_TRUSTED_ORIGINS!, + origin: process.env.API_TRUSTED_ORIGINS?.split(',') ?? [], allowHeaders: ['Content-Type', 'Authorization'], allowMethods: ['POST', 'GET', 'OPTIONS'], exposeHeaders: ['Content-Length'], diff --git a/apps/api/src/routes/calendars.ts b/apps/api/src/routes/calendars.ts index 91d1d5d..6c63bda 100644 --- a/apps/api/src/routes/calendars.ts +++ b/apps/api/src/routes/calendars.ts @@ -10,7 +10,7 @@ const calendars = new Hono(); calendars.use( '/*', cors({ - origin: process.env.BETTER_AUTH_TRUSTED_ORIGINS!, + origin: process.env.API_TRUSTED_ORIGINS?.split(',') ?? [], exposeHeaders: ['Content-Length'], maxAge: 600, credentials: true, diff --git a/apps/docs/.env.example b/apps/docs/.env.example index c7fb151..1883dc2 100644 --- a/apps/docs/.env.example +++ b/apps/docs/.env.example @@ -1,2 +1,8 @@ ORAMA_PRIVATE_API_KEY="" -ORAMA_INDEX_ID="" \ No newline at end of file +ORAMA_INDEX_ID="" + +NEXT_PUBLIC_ORAMA_API_KEY="" +NEXT_PUBLIC_ORAMA_ENDPOINT="" + +# Environment +NODE_ENV=development \ No newline at end of file diff --git a/apps/docs/content/docs/concepts/environment-variables.mdx b/apps/docs/content/docs/concepts/environment-variables.mdx index 37cd908..40bcd37 100644 --- a/apps/docs/content/docs/concepts/environment-variables.mdx +++ b/apps/docs/content/docs/concepts/environment-variables.mdx @@ -285,16 +285,21 @@ TURSO_AUTH_TOKEN="" ### Authentication Configuration + + When deploying to Google Cloud Run with a custom domain, you should set the + `BETTER_AUTH_URL` environment variable to the custom domain. + + These values are used by the api to perform authentication. Please follow the [guide](/docs/concepts/api/authentication) for more details: ```txt title=".env.development.local" BETTER_AUTH_SECRET="" BETTER_AUTH_URL="http://localhost:3001" -BETTER_AUTH_TRUSTED_ORIGINS="http://localhost:5173" +API_TRUSTED_ORIGINS="http://localhost:5173" ``` - The `BETTER_AUTH_TRUSTED_ORIGINS` is not only used for authentication but also + The `API_TRUSTED_ORIGINS` is not only used for authentication but also for CORS configuration. diff --git a/apps/docs/content/docs/guides/deployment/firebase.mdx b/apps/docs/content/docs/guides/deployment/firebase.mdx index 1799577..80f7f99 100644 --- a/apps/docs/content/docs/guides/deployment/firebase.mdx +++ b/apps/docs/content/docs/guides/deployment/firebase.mdx @@ -30,8 +30,7 @@ For more information on Firebase Hosting, refer to the official [Firebase Hostin If not already, create a Firebase project in the Firebase Console: 1. Create a project named **Transcript Seeker**. -2. Then, create two new web apps: - - `transcript-seeker-api`: Replace `transcript-seeker-api-c8419` in `firebase.json` and `.firebaserc` with this new ID. +2. Then, create a new web app: - `transcript-seeker-proxy`: Replace `transcript-seeker-proxy` in `firebase.json` and `.firebaserc` with this new ID. 3. Navigate to **Hosting** and click "Get Started." 4. Finally, Replace `transcript-seeker-bdc29` in `firebase.json` and `.firebaserc` with your project id. (This is for firebase hosting, when you click on get started it automatically creates a hosting project with ur app id) @@ -197,6 +196,10 @@ The command below builds and deploys the Cloud Run service. Modify the `SERVICE_ can replace `COMMIT_SHA` with a unique identifier. + + If you have already deployed the frontend and are encountering a CORS error, it may be due to the API being built for production. Once the build is complete, the CORS error should be resolved. + + ```bash title="Terminal" export COMMIT_SHA=$(git rev-parse --short HEAD) export DEPLOY_REGION="us-central1" diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs index 6ee83fd..afbdff9 100644 --- a/apps/docs/next.config.mjs +++ b/apps/docs/next.config.mjs @@ -10,16 +10,16 @@ const withMDX = createMDX(); /** @type {import('next').NextConfig} */ const config = { - output: "export", + // output: "export", reactStrictMode: true, eslint: { // Replaced by root workspace command ignoreDuringBuilds: true, }, - serverExternalPackages: ["ts-morph", "typescript"], - images: { - unoptimized: true, - }, + // serverExternalPackages: ["ts-morph", "typescript"], + // images: { + // unoptimized: true, + // }, }; export default withAnalyzer(withMDX(config)); diff --git a/apps/proxy/.env.example b/apps/proxy/.env.example index 0506a2f..19d28ee 100644 --- a/apps/proxy/.env.example +++ b/apps/proxy/.env.example @@ -7,4 +7,7 @@ NITRO_MEETINGBAAS_S3_URL=https://s3.eu-west-3.amazonaws.com/meeting-baas-video # Firebase Deployment Config # Advanced, only use if using firebase deployment -# NITRO_PRESET=firebase \ No newline at end of file +# NITRO_PRESET=firebase + +# Environment +NODE_ENV=development \ No newline at end of file diff --git a/apps/web/package.json b/apps/web/package.json index e3e9ddc..ec2dbd5 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -29,7 +29,7 @@ "@tanstack/react-table": "^8.19.2", "@vidstack/react": "^1.11.24", "assemblyai": "^4.6.1", - "better-auth": "0.7.1-beta.6", + "better-auth": "0.7.2", "date-fns": "^3.6.0", "dotenv-cli": "catalog:", "hls.js": "^1.5.13", diff --git a/apps/web/src/components/settings/settings-form.tsx b/apps/web/src/components/settings/settings-form.tsx index 90e1e5c..aa765af 100644 --- a/apps/web/src/components/settings/settings-form.tsx +++ b/apps/web/src/components/settings/settings-form.tsx @@ -251,16 +251,16 @@ export function SettingsForm() { - {session.user + {session?.user ? JSON.stringify(session.user) : isSessionLoading ? 'loading...' : 'not authenticated'} - {session.user && } + {session?.user && } - {!session.user && ( + {!session?.user && ( Login diff --git a/apps/web/src/routes/login.tsx b/apps/web/src/routes/login.tsx index 35c5afb..7bd7046 100644 --- a/apps/web/src/routes/login.tsx +++ b/apps/web/src/routes/login.tsx @@ -9,7 +9,7 @@ function LoginPage() { const [isPending, startTransition] = useTransition(); return ( -
+

Login

@@ -22,7 +22,8 @@ function LoginPage() { startTransition(async () => { await signIn.social({ provider: 'google', - callbackURL: '/meetings', + // todo: remove this when better auth resolves the callback url automatically + callbackURL: new URL('/meetings', document.location as any).href, }); }); }} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 74f3781..94432ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,8 +76,8 @@ importers: specifier: ^0.14.0 version: 0.14.0 better-auth: - specifier: 0.7.1-beta.6 - version: 0.7.1-beta.6(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)) + specifier: 0.7.2 + version: 0.7.2(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)) dotenv: specifier: ^16.4.5 version: 16.4.5 @@ -373,8 +373,8 @@ importers: specifier: ^4.6.1 version: 4.7.1 better-auth: - specifier: 0.7.1-beta.6 - version: 0.7.1-beta.6(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)) + specifier: 0.7.2 + version: 0.7.2(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)) date-fns: specifier: ^3.6.0 version: 3.6.0 @@ -4750,11 +4750,11 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - better-auth@0.7.1-beta.6: - resolution: {integrity: sha512-rRDtdxWEtVfcPRBaq88EFhJhjWpoVgO9EGECPUaJO619UmSf+cNO9Ush1X5h6mv82rI8E41sKZnx68TgAfIstQ==} + better-auth@0.7.2: + resolution: {integrity: sha512-a6hdsrvmya1Msvms3pXxmRiauDBc035sqhLyqKXOQQttRpmq3M1zFHPVuaXVx1BWOqDtS9UXl0XKZG7Ywyxu3Q==} - better-call@0.2.14-beta.2: - resolution: {integrity: sha512-j3hFMkD7xZNBXT1lFxrNFbz2Q5wwrzJ+3h+yDWJTVGrbkw7iL0gTA6ZY4hl1Nv3LCgW65wNnGJno9E8vy35oVA==} + better-call@0.2.14-beta.3: + resolution: {integrity: sha512-lA54ETanzM0xUZnQt6lm3BdTr4gVDyAe1DNpCQSTYUnwnGGOmQG8ob0FYivVd0XHsHQK68r01GB5c6cUuu4llQ==} bignumber.js@9.1.2: resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} @@ -13446,7 +13446,7 @@ snapshots: base64-js@1.5.1: {} - better-auth@0.7.1-beta.6(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)): + better-auth@0.7.2(react@19.0.0-rc-4d577fd2-20241104)(solid-js@1.9.3)(vue@3.5.12(typescript@5.6.3)): dependencies: '@better-fetch/fetch': 1.1.12 '@nanostores/query': 0.3.4(nanostores@0.11.3) @@ -13457,7 +13457,7 @@ snapshots: '@noble/hashes': 1.5.0 '@simplewebauthn/browser': 10.0.0 '@simplewebauthn/server': 10.0.1 - better-call: 0.2.14-beta.2 + better-call: 0.2.14-beta.3 consola: 3.2.3 defu: 6.1.4 jose: 5.9.6 @@ -13475,7 +13475,7 @@ snapshots: - solid-js - vue - better-call@0.2.14-beta.2: + better-call@0.2.14-beta.3: dependencies: '@better-fetch/fetch': 1.1.12 rou3: 0.5.1 diff --git a/scripts/one-click-deploy.sh b/scripts/one-click-deploy.sh index 3a80cb0..58b3c1b 100644 --- a/scripts/one-click-deploy.sh +++ b/scripts/one-click-deploy.sh @@ -16,21 +16,21 @@ echo "Environment set to production." # Build and deploy apps/web echo "Building and deploying apps/web..." cd apps/web -pnpm build +NODE_ENV=production pnpm build firebase deploy || { echo "Firebase deploy for apps/web failed"; exit 1; } cd ../.. # Build and deploy apps/proxy echo "Building and deploying apps/proxy..." cd apps/proxy -pnpm build +NODE_ENV=production pnpm build firebase deploy || { echo "Firebase deploy for apps/proxy failed"; exit 1; } cd ../.. # Build apps/api echo "Building apps/api..." cd apps/api -pnpm build || { echo "Build failed for apps/api"; exit 1; } +NODE_ENV=production pnpm build || { echo "Build failed for apps/api"; exit 1; } cd ../.. # Log Cloud Run deployment @@ -40,7 +40,7 @@ echo "Preparing for Cloud Run deployment..." export COMMIT_SHA=$(git rev-parse --short HEAD) export DEPLOY_REGION="us-central1" export SERVICE_NAME="transcript-seeker-api-prod" -export GITHUB_USERNAME="Meeting-Baas" +export GITHUB_USERNAME="techwithanirudh" echo "Environment variables set:" echo " COMMIT_SHA: $COMMIT_SHA" diff --git a/turbo.json b/turbo.json index b8cbf69..db50f2a 100644 --- a/turbo.json +++ b/turbo.json @@ -67,8 +67,11 @@ "TURSO_AUTH_TOKEN", "BETTER_AUTH_SECRET", "BETTER_AUTH_URL", - "BETTER_AUTH_TRUSTED_ORIGINS", - "ORAMA_PRIVATE_API_KEY" + "API_TRUSTED_ORIGINS", + "ORAMA_PRIVATE_API_KEY", + "ORAMA_INDEX_ID", + "NEXT_PUBLIC_ORAMA_API_KEY", + "NEXT_PUBLIC_ORAMA_ENDPOINT" ], "globalPassThroughEnv": [ "NODE_ENV",