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

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