graphql fix

This commit is contained in:
2026-05-20 17:12:37 +05:30
parent d556d1a73e
commit a5fcb5210c
3 changed files with 16 additions and 16 deletions

View File

@@ -91,10 +91,12 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin
</div>
{/* URL bar */}
<div className="bg-white border border-slate-200/80 rounded-xl p-3.5 font-mono text-sm text-slate-600 break-all shadow-sm flex items-center gap-2 group-hover/row:border-brand-300 transition-colors">
<Server size={14} className="text-brand-400 shrink-0" />
<span className="opacity-60 hidden sm:inline">{baseUrl}</span>
<span className="font-semibold text-slate-800">{path}</span>
<div className="bg-white border border-slate-200/80 rounded-xl p-3.5 font-mono text-sm shadow-sm flex items-start gap-2 group-hover/row:border-brand-300 transition-colors min-w-0">
<Server size={14} className="text-brand-400 shrink-0 mt-0.5" />
<div className="min-w-0 flex-1">
<div className="text-xs text-slate-400 truncate">{baseUrl}</div>
<div className="font-semibold text-slate-800 break-all">{path}</div>
</div>
</div>
{/* Query Parameters */}
@@ -148,7 +150,7 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin
</pre>
</div>
) : (
<div className="flex-1 p-8 flex flex-col justify-center">
<div className="flex-1 p-8 flex flex-col justify-start">
<div className="text-[11px] font-bold text-slate-400 mb-4 uppercase tracking-wider flex items-center gap-2">
<Server size={14} className="text-brand-400" /> Full Request URL
</div>

View File

@@ -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
}

View File

@@ -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)
})
}
}
}
}