From 5755030f1bda1d5eee23f323a35493001423a7da Mon Sep 17 00:00:00 2001 From: Daniel Costa Date: Mon, 4 Aug 2025 18:32:02 +0100 Subject: [PATCH] Relative paths for assets, playground requests and fonts --- packages/cubejs-playground/src/App.tsx | 4 ++-- .../LivePreviewContext/LivePreviewContextProvider.tsx | 6 +++--- packages/cubejs-playground/src/index.tsx | 2 +- .../src/pages/ConnectionWizard/ConnectionWizardPage.tsx | 4 ++-- packages/cubejs-playground/src/pages/Index/IndexPage.tsx | 2 +- packages/cubejs-playground/src/pages/Schema/SchemaPage.tsx | 6 +++--- packages/cubejs-playground/vite.config.ts | 1 + 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/cubejs-playground/src/App.tsx b/packages/cubejs-playground/src/App.tsx index 72367703250ad..80d25e1e6143c 100755 --- a/packages/cubejs-playground/src/App.tsx +++ b/packages/cubejs-playground/src/App.tsx @@ -63,7 +63,7 @@ class App extends Component, AppState> { }); }); - const res = await fetch('/playground/context'); + const res = await fetch('playground/context'); const context = await res.json(); setTelemetry(context.telemetry); @@ -112,7 +112,7 @@ class App extends Component, AppState> { - +
diff --git a/packages/cubejs-playground/src/components/LivePreviewContext/LivePreviewContextProvider.tsx b/packages/cubejs-playground/src/components/LivePreviewContext/LivePreviewContextProvider.tsx index 4e9241fe0d434..676fff86eccfb 100644 --- a/packages/cubejs-playground/src/components/LivePreviewContext/LivePreviewContextProvider.tsx +++ b/packages/cubejs-playground/src/components/LivePreviewContext/LivePreviewContextProvider.tsx @@ -70,7 +70,7 @@ const useLivePreview = (disabled = false) => { // }, [status]); const fetchStatus = () => { - return fetch('/playground/live-preview/status') + return fetch('playground/live-preview/status') .then((res) => res.json()) .then((status) => { setStatus({ @@ -81,7 +81,7 @@ const useLivePreview = (disabled = false) => { }; const createTokenWithPayload = async (payload): Promise => { - const res = await fetch('/playground/live-preview/token', { + const res = await fetch('playground/live-preview/token', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -108,7 +108,7 @@ const useLivePreview = (disabled = false) => { statusLivePreview: status, createTokenWithPayload, stopLivePreview: async (): Promise => { - await fetch('/playground/live-preview/stop'); + await fetch('playground/live-preview/stop'); await fetchStatus(); return true; }, diff --git a/packages/cubejs-playground/src/index.tsx b/packages/cubejs-playground/src/index.tsx index 50f4c39a76f0b..0baea38a74d63 100755 --- a/packages/cubejs-playground/src/index.tsx +++ b/packages/cubejs-playground/src/index.tsx @@ -26,7 +26,7 @@ async function onTokenPayloadChange(payload: Record, token) { return token; } - const response = await fetch('/playground/token', { + const response = await fetch('playground/token', { method: 'post', headers: { 'Content-Type': 'application/json', diff --git a/packages/cubejs-playground/src/pages/ConnectionWizard/ConnectionWizardPage.tsx b/packages/cubejs-playground/src/pages/ConnectionWizard/ConnectionWizardPage.tsx index 2b4da4d705c68..da0242d92f0f3 100644 --- a/packages/cubejs-playground/src/pages/ConnectionWizard/ConnectionWizardPage.tsx +++ b/packages/cubejs-playground/src/pages/ConnectionWizard/ConnectionWizardPage.tsx @@ -63,7 +63,7 @@ async function testConnection(variables: Record) { } async function saveConnection(variables: Record) { - await fetch('/playground/env', { + await fetch('playground/env', { method: 'post', headers: { 'Content-Type': 'application/json', @@ -174,7 +174,7 @@ export function ConnectionWizardPage({ history }) { } { - const response = await fetch('/playground/driver', { + const response = await fetch('playground/driver', { method: 'post', headers: { 'Content-Type': 'application/json', diff --git a/packages/cubejs-playground/src/pages/Index/IndexPage.tsx b/packages/cubejs-playground/src/pages/Index/IndexPage.tsx index 0c8a0a33adfd3..91f0a20869652 100644 --- a/packages/cubejs-playground/src/pages/Index/IndexPage.tsx +++ b/packages/cubejs-playground/src/pages/Index/IndexPage.tsx @@ -12,7 +12,7 @@ export function IndexPage() { useEffect(() => { async function loadFiles() { - const res = await fetch('/playground/files'); + const res = await fetch('playground/files'); const result = await res.json(); if (result.error?.includes('Model files not found')) { diff --git a/packages/cubejs-playground/src/pages/Schema/SchemaPage.tsx b/packages/cubejs-playground/src/pages/Schema/SchemaPage.tsx index 1c7a6deef2285..f1d1ced015fc5 100644 --- a/packages/cubejs-playground/src/pages/Schema/SchemaPage.tsx +++ b/packages/cubejs-playground/src/pages/Schema/SchemaPage.tsx @@ -78,7 +78,7 @@ export class SchemaPage extends Component { async loadDBSchema() { this.setState({ schemaLoading: true }); try { - const res = await playgroundFetch('/playground/db-schema'); + const res = await playgroundFetch('playground/db-schema'); const result = await res.json(); this.setState({ tablesSchema: result.tablesSchema, @@ -91,7 +91,7 @@ export class SchemaPage extends Component { } async loadFiles() { - const res = await playgroundFetch('/playground/files'); + const res = await playgroundFetch('playground/files'); const result = await res.json(); this.setState({ files: result.files, @@ -106,7 +106,7 @@ export class SchemaPage extends Component { const options = { format }; playgroundAction('Generate Schema', options); - const res = await playgroundFetch('/playground/generate-schema', { + const res = await playgroundFetch('playground/generate-schema', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/packages/cubejs-playground/vite.config.ts b/packages/cubejs-playground/vite.config.ts index 9d3dbc33c44fa..e0fb55b62e468 100644 --- a/packages/cubejs-playground/vite.config.ts +++ b/packages/cubejs-playground/vite.config.ts @@ -4,6 +4,7 @@ import react from '@vitejs/plugin-react'; import environmentPlugin from 'vite-plugin-environment'; export default defineConfig(({ mode }) => ({ + base: './', build: { outDir: 'build', target: 'es2018',