I'm trying to configure dataProvider
to include credentials/cookies, and following official repo's guide on sending Credentials To The API and other question, I managed to produce a typescript version of it:
import * as ra_core from "ra-core";
import { fetchUtils } from "react-admin";
import simpleRestProvider from "ra-data-json-server";
const httpClient = (url: any, options?: ra_core.Options) => {
if (options) { // Have to do a null check
console.log("run options"); // It doesn't run from here
options.credentials = "include";
}
console.log("run httpClient"); // It only runs here
return fetchUtils.fetchJson(url, options);
};
const dataProvider= simpleRestProvider("http://localhost:3000", httpClient);
return <Admin dataProvider={dataProvider}>...</Admin>
Above code doesn't send cookies to server, as the httpClient
takes an optional options
, and performing null check skips it entirely. Is there any fix for this?