apifix
This commit is contained in:
@@ -2,14 +2,18 @@ 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'
|
const ADMIN_SECRET = 'nearle-admin-secret'
|
||||||
|
|
||||||
function toProxyPath(fullUrl) {
|
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.
|
// 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
|
return fullUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user