Configure mande for SSR (Server-Side Rendering)
mainWhen running on a server (e.g., Node.js), mande requires a fetch polyfill and absolute URLs (including the domain), as relative paths like /api/... will not resolve.
// Example setup for SSR
export const BASE_URL = process.server
? (process.env.NODE_ENV !== 'production' ? 'http://localhost:3000' : 'https://example.com')
: '' // Client uses relative paths
const fetchPolyfill = process.server ? require('node-fetch') : fetch
const contents = mande(BASE_URL + '/api', {}, fetchPolyfill)export const BASE_URL = process.server
? process.env.NODE_ENV !== 'production'
? 'http://localhost:3000'
: 'https://example.com'
: // on client, do not add the domain, so urls end up like `/api/something`
''
const fetchPolyfill = process.server ? require('node-fetch') : fetch
const contents = mande(BASE_URL + '/api', {}, fetchPolyfill)