@@ -1,6 +1,5 @@
|
|||||||
import { headers as nextHeaders } from 'next/headers'
|
import { headers as nextHeaders } from 'next/headers'
|
||||||
|
import { BASE_URL } from '@/lib/utils'
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current session from Better Auth backend (server-side)
|
* Get the current session from Better Auth backend (server-side)
|
||||||
@@ -10,7 +9,7 @@ export async function getSession() {
|
|||||||
const headersList = await nextHeaders()
|
const headersList = await nextHeaders()
|
||||||
|
|
||||||
// Make authenticated request to the auth backend to get session
|
// Make authenticated request to the auth backend to get session
|
||||||
const response = await fetch(`${API_URL}/api/auth/get-session`, {
|
const response = await fetch(`${BASE_URL}/api/auth/get-session`, {
|
||||||
headers: {
|
headers: {
|
||||||
cookie: headersList.get('cookie') || '',
|
cookie: headersList.get('cookie') || '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import { createAuth } from '@pascal-app/auth/server'
|
import { createAuth } from '@pascal-app/auth/server'
|
||||||
import { db } from '@pascal-app/db'
|
import { db } from '@pascal-app/db'
|
||||||
import { Resend } from 'resend'
|
import { Resend } from 'resend'
|
||||||
|
import { BASE_URL } from './utils'
|
||||||
|
|
||||||
const resend = process.env.RESEND_API_KEY ? new Resend(process.env.RESEND_API_KEY) : null
|
// Initialize Resend only if API key is available
|
||||||
|
const resendApiKey = process.env.RESEND_API_KEY
|
||||||
|
const resend = resendApiKey && resendApiKey.trim() !== '' ? new Resend(resendApiKey) : null
|
||||||
|
|
||||||
export const auth = createAuth({
|
export const auth = createAuth({
|
||||||
db,
|
db,
|
||||||
appName: 'Pascal Editor',
|
appName: 'Pascal Editor',
|
||||||
baseURL: process.env.BETTER_AUTH_URL!,
|
baseURL: BASE_URL,
|
||||||
secret: process.env.BETTER_AUTH_SECRET!,
|
secret: process.env.BETTER_AUTH_SECRET!,
|
||||||
sendMagicLink: async ({ email, url }) => {
|
sendMagicLink: async ({ email, url }) => {
|
||||||
if (!resend) {
|
if (!resend) {
|
||||||
|
|||||||
@@ -4,3 +4,41 @@ import { twMerge } from 'tailwind-merge'
|
|||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isDevelopment =
|
||||||
|
process.env.NODE_ENV === 'development' ||
|
||||||
|
process.env.NEXT_PUBLIC_VERCEL_ENV === 'development'
|
||||||
|
|
||||||
|
export const isProduction =
|
||||||
|
process.env.NODE_ENV === 'production' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
|
||||||
|
|
||||||
|
export const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL for the application
|
||||||
|
* Uses NEXT_PUBLIC_* variables which are available at build time
|
||||||
|
*/
|
||||||
|
export const BASE_URL = (() => {
|
||||||
|
// Development: localhost
|
||||||
|
if (isDevelopment) {
|
||||||
|
return process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3000}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preview deployments: use Vercel branch URL
|
||||||
|
if (isPreview && process.env.NEXT_PUBLIC_VERCEL_URL) {
|
||||||
|
return `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Production: use custom domain or Vercel production URL
|
||||||
|
if (isProduction) {
|
||||||
|
return (
|
||||||
|
process.env.NEXT_PUBLIC_APP_URL ||
|
||||||
|
(process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
|
||||||
|
? `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`
|
||||||
|
: 'https://editor.pascal.app')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback (should never reach here in normal operation)
|
||||||
|
return process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
||||||
|
})()
|
||||||
|
|||||||
@@ -11,8 +11,32 @@ function getAuthURL(): string {
|
|||||||
return window.location.origin
|
return window.location.origin
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSR fallback
|
// SSR fallback - detect environment from Vercel variables
|
||||||
return process.env.BETTER_AUTH_URL || 'http://localhost:3000'
|
const isDevelopment =
|
||||||
|
process.env.NODE_ENV === 'development' ||
|
||||||
|
process.env.NEXT_PUBLIC_VERCEL_ENV === 'development'
|
||||||
|
const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
|
||||||
|
const isProduction =
|
||||||
|
process.env.NODE_ENV === 'production' || process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
|
||||||
|
|
||||||
|
if (isDevelopment) {
|
||||||
|
return process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3000}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPreview && process.env.NEXT_PUBLIC_VERCEL_URL) {
|
||||||
|
return `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProduction) {
|
||||||
|
return (
|
||||||
|
process.env.NEXT_PUBLIC_APP_URL ||
|
||||||
|
(process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
|
||||||
|
? `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`
|
||||||
|
: 'https://editor.pascal.app')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'http://localhost:3000'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
v2.186.0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
postgresql://postgres.byrpxoiotywskoojsrzd@aws-1-us-east-1.pooler.supabase.com:5432/postgres
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
17.6.1.063
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
byrpxoiotywskoojsrzd
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
v14.1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fix-optimized-search-function
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
v1.37.7
|
||||||
Reference in New Issue
Block a user