endpointfix
This commit is contained in:
@@ -2,17 +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, REST_BASE_URL } from '../data/topics'
|
import { LEGACY_BASE_URL } from '../data/topics'
|
||||||
|
|
||||||
const ADMIN_SECRET = 'nearle-admin-secret'
|
const ADMIN_SECRET = 'nearle-admin-secret'
|
||||||
|
|
||||||
function toProxyPath(fullUrl, baseUrl) {
|
function toProxyPath(fullUrl) {
|
||||||
// REST (jupiter.nearle.app): strip base so /live/... goes through Vite proxy
|
// Always fetch the full URL directly.
|
||||||
if (baseUrl === REST_BASE_URL && fullUrl.startsWith(REST_BASE_URL)) {
|
// Legacy (api.workolik.com): CORS open, admin secret injected in headers.
|
||||||
return fullUrl.slice(REST_BASE_URL.length)
|
// REST (jupiter.nearle.app): fetched directly, no proxy needed.
|
||||||
}
|
|
||||||
// Legacy (api.workolik.com): CORS is open — fetch the full URL directly.
|
|
||||||
// Admin secret is injected in the request header, so no proxy needed.
|
|
||||||
return fullUrl
|
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 ms = Date.now() - start
|
||||||
const text = await res.text()
|
const text = await res.text()
|
||||||
let body
|
let body
|
||||||
|
|||||||
Reference in New Issue
Block a user