graphql fix
This commit is contained in:
@@ -91,10 +91,12 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* URL bar */}
|
{/* 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">
|
<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" />
|
<Server size={14} className="text-brand-400 shrink-0 mt-0.5" />
|
||||||
<span className="opacity-60 hidden sm:inline">{baseUrl}</span>
|
<div className="min-w-0 flex-1">
|
||||||
<span className="font-semibold text-slate-800">{path}</span>
|
<div className="text-xs text-slate-400 truncate">{baseUrl}</div>
|
||||||
|
<div className="font-semibold text-slate-800 break-all">{path}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Query Parameters */}
|
{/* Query Parameters */}
|
||||||
@@ -148,7 +150,7 @@ export default function EndpointCard({ endpoint, baseUrl, onSend, result, loadin
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</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">
|
<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
|
<Server size={14} className="text-brand-400" /> Full Request URL
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { useEffect, useRef, useState } from 'react'
|
|||||||
import EndpointCard from './EndpointCard'
|
import EndpointCard from './EndpointCard'
|
||||||
import { getTopicIcon } from '../lib/icons'
|
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) {
|
function toProxyPath(fullUrl, baseUrl) {
|
||||||
// Only proxy the legacy GraphQL API (to inject the admin secret via server)
|
if (fullUrl.startsWith(baseUrl)) {
|
||||||
if (baseUrl === LEGACY_BASE_URL && fullUrl.startsWith(baseUrl)) {
|
|
||||||
return fullUrl.slice(baseUrl.length)
|
return fullUrl.slice(baseUrl.length)
|
||||||
}
|
}
|
||||||
// Let the browser hit the new REST API directly (it supports CORS)
|
|
||||||
return fullUrl
|
return fullUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,9 +44,12 @@ export default function TopicView({ topic, searchQuery }) {
|
|||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const headers = { 'Content-Type': 'application/json' }
|
||||||
|
if (topic.type === 'legacy') headers['x-hasura-admin-secret'] = ADMIN_SECRET
|
||||||
|
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: endpoint.method,
|
method: endpoint.method,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers,
|
||||||
signal: controller.signal
|
signal: controller.signal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,9 @@ export default defineConfig(({ mode }) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'/live': {
|
'/live': {
|
||||||
target: 'https://fiesta.nearle.app',
|
target: 'https://jupiter.nearle.app',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: true,
|
secure: true,
|
||||||
configure: (proxy) => {
|
|
||||||
proxy.on('proxyReq', (proxyReq) => {
|
|
||||||
if (secret) proxyReq.setHeader('x-hasura-admin-secret', secret)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user