UNPKG

component-slider

Version:

used to show react components in carousal format

32 lines (25 loc) 723 B
import fetch from '../core/fetch'; function createFetchKnowingCookie({ cookie }) { if (!process.env.BROWSER) { return (url, options = {}) => { const isLocalUrl = /^\/($|[^\/])/.test(url); // pass cookie only for itself. // We can't know cookies for other sites BTW if (isLocalUrl && options.credentials === 'include') { const headers = { ...options.headers, cookie, }; return fetch(url, { ...options, headers }); } return fetch(url, options); }; } return fetch; } export default function createHelpers(config) { const fetchKnowingCookie = createFetchKnowingCookie(config); return { fetch: fetchKnowingCookie }; }