chore: initial project scaffold: frontend/src/dataProvider.ts

This commit is contained in:
2026-04-22 06:51:06 +00:00
parent 687a79bf9a
commit aa8f7d740c

View File

@@ -0,0 +1,16 @@
import simpleRestProvider from 'ra-data-simple-rest';
import { fetchUtils } from 'react-admin';
import { getToken } from './authProvider';
const httpClient = (url: string, options: fetchUtils.Options = {}) => {
const token = getToken();
const headers = new Headers(options.headers);
if (token) {
headers.set('Authorization', `Bearer ${token}`);
}
return fetchUtils.fetchJson(url, { ...options, headers });
};
const apiUrl = '/api';
export const dataProvider = simpleRestProvider(apiUrl, httpClient);