endpointfix

This commit is contained in:
2026-05-20 17:38:03 +05:30
parent 7bf75d9502
commit b14975dd9b

View File

@@ -2,17 +2,14 @@ import { useEffect, useRef, useState } from 'react'
import EndpointCard from './EndpointCard'
import { getTopicIcon } from '../lib/icons'
import { LEGACY_BASE_URL, REST_BASE_URL } from '../data/topics'
import { LEGACY_BASE_URL } from '../data/topics'
const ADMIN_SECRET = 'nearle-admin-secret'
function toProxyPath(fullUrl, baseUrl) {
// REST (jupiter.nearle.app): strip base so /live/... goes through Vite proxy
if (baseUrl === REST_BASE_URL && fullUrl.startsWith(REST_BASE_URL)) {
return fullUrl.slice(REST_BASE_URL.length)
}
// Legacy (api.workolik.com): CORS is open — fetch the full URL directly.
// Admin secret is injected in the request header, so no proxy needed.
function toProxyPath(fullUrl) {
// Always fetch the full URL directly.
// Legacy (api.workolik.com): CORS open, admin secret injected in headers.
// REST (jupiter.nearle.app): fetched directly, no proxy needed.
return fullUrl
}
@@ -69,7 +66,7 @@ export default function TopicView({ topic, searchQuery }) {
}
}
const res = await fetch(toProxyPath(composedUrl, topic.baseUrl), fetchOptions)
const res = await fetch(toProxyPath(composedUrl), fetchOptions)
const ms = Date.now() - start
const text = await res.text()
let body