Add BaseURL configuration (fixes #103)

This commit is contained in:
Deluan
2020-04-03 17:50:42 -04:00
parent b8eb22d162
commit 75cd21da1f
17 changed files with 61 additions and 25 deletions
+5 -3
View File
@@ -1,10 +1,12 @@
import { fetchUtils } from 'react-admin'
import jsonServerProvider from 'ra-data-json-server'
import baseUrl from './utils/baseUrl'
const baseUrl = '/app/api'
const restUrl = '/app/api'
const httpClient = (url, options = {}) => {
url = url.replace(baseUrl + '/albumSong', baseUrl + '/song')
url = baseUrl(url)
url = url.replace(restUrl + '/albumSong', restUrl + '/song')
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' })
}
@@ -22,6 +24,6 @@ const httpClient = (url, options = {}) => {
})
}
const dataProvider = jsonServerProvider(baseUrl, httpClient)
const dataProvider = jsonServerProvider(restUrl, httpClient)
export default dataProvider