diff --git a/src/components/TopicView.jsx b/src/components/TopicView.jsx index 0a25faf..3ed9b4f 100644 --- a/src/components/TopicView.jsx +++ b/src/components/TopicView.jsx @@ -2,14 +2,18 @@ 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) { - // Always fetch the full URL directly. + // In dev, route REST through the Vite proxy (/live → jupiter.nearle.app) + // to bypass CORS restrictions on localhost. + if (import.meta.env.DEV && fullUrl.startsWith(REST_BASE_URL)) { + return fullUrl.slice(REST_BASE_URL.length) + } // Legacy (api.workolik.com): CORS open, admin secret injected in headers. - // REST (jupiter.nearle.app): fetched directly, no proxy needed. + // REST in production: deployed origin is whitelisted by jupiter.nearle.app. return fullUrl }