fix(api): Add INTERNAL_DIRECTUS_URL support for SSR connectivity

This commit is contained in:
cawcenter
2025-12-12 22:17:40 -05:00
parent 1c0180de0d
commit 64bdedfe5c

View File

@@ -12,8 +12,11 @@ import {
} from '@directus/sdk'; } from '@directus/sdk';
import type { SparkSchema } from '@/types/schema'; import type { SparkSchema } from '@/types/schema';
const DIRECTUS_URL = import.meta.env.PUBLIC_DIRECTUS_URL || 'http://localhost:8055'; const PUBLIC_URL = import.meta.env.PUBLIC_DIRECTUS_URL || 'http://localhost:8055';
const DIRECTUS_TOKEN = import.meta.env.DIRECTUS_ADMIN_TOKEN || ''; const INTERNAL_URL = import.meta.env.INTERNAL_DIRECTUS_URL || PUBLIC_URL;
// Select URL based on environment (Server vs Client)
const DIRECTUS_URL = (typeof window === 'undefined') ? INTERNAL_URL : PUBLIC_URL;
/** /**
* Creates a typed Directus client for the Spark Platform * Creates a typed Directus client for the Spark Platform