From a5fcb5210c3445509e41782124f9bc42e9a5685b Mon Sep 17 00:00:00 2001 From: Suriya Date: Wed, 20 May 2026 17:12:37 +0530 Subject: [PATCH] graphql fix --- src/components/EndpointCard.jsx | 12 +++++++----- src/components/TopicView.jsx | 13 ++++++++----- vite.config.js | 7 +------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/EndpointCard.jsx b/src/components/EndpointCard.jsx index 779b270..3a2e30b 100644 --- a/src/components/EndpointCard.jsx +++ b/src/components/EndpointCard.jsx @@ -91,10 +91,12 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin {/* URL bar */} -
- - {baseUrl} - {path} +
+ +
+
{baseUrl}
+
{path}
+
{/* Query Parameters */} @@ -148,7 +150,7 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin
) : ( -
+
Full Request URL
diff --git a/src/components/TopicView.jsx b/src/components/TopicView.jsx index b6afd1d..13661df 100644 --- a/src/components/TopicView.jsx +++ b/src/components/TopicView.jsx @@ -2,14 +2,14 @@ import { useEffect, useRef, useState } from 'react' import EndpointCard from './EndpointCard' import { getTopicIcon } from '../lib/icons' -import { LEGACY_BASE_URL } from '../data/topics' +import { LEGACY_BASE_URL, REST_BASE_URL } from '../data/topics' + +const ADMIN_SECRET = 'nearle-admin-secret' function toProxyPath(fullUrl, baseUrl) { - // Only proxy the legacy GraphQL API (to inject the admin secret via server) - if (baseUrl === LEGACY_BASE_URL && fullUrl.startsWith(baseUrl)) { + if (fullUrl.startsWith(baseUrl)) { return fullUrl.slice(baseUrl.length) } - // Let the browser hit the new REST API directly (it supports CORS) return fullUrl } @@ -44,9 +44,12 @@ export default function TopicView({ topic, searchQuery }) { const start = Date.now() try { + const headers = { 'Content-Type': 'application/json' } + if (topic.type === 'legacy') headers['x-hasura-admin-secret'] = ADMIN_SECRET + const fetchOptions = { method: endpoint.method, - headers: { 'Content-Type': 'application/json' }, + headers, signal: controller.signal } diff --git a/vite.config.js b/vite.config.js index 812b7d6..51182d8 100644 --- a/vite.config.js +++ b/vite.config.js @@ -28,14 +28,9 @@ export default defineConfig(({ mode }) => { } }, '/live': { - target: 'https://fiesta.nearle.app', + target: 'https://jupiter.nearle.app', changeOrigin: true, secure: true, - configure: (proxy) => { - proxy.on('proxyReq', (proxyReq) => { - if (secret) proxyReq.setHeader('x-hasura-admin-secret', secret) - }) - } } } }