diff --git a/packages/core/helper-plugin/lib/src/utils/fetchClient/index.js b/packages/core/helper-plugin/lib/src/utils/fetchClient/index.js index 515bec88a7..522d395cd3 100644 --- a/packages/core/helper-plugin/lib/src/utils/fetchClient/index.js +++ b/packages/core/helper-plugin/lib/src/utils/fetchClient/index.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import auth from '../../utils/auth'; +import auth from '../auth'; export const reqInterceptor = async (config) => { config.headers = { @@ -44,4 +44,4 @@ export const fetchClient = ({ baseURL }) => { return instance; }; -export default fetchClient({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL }); +export default fetchClient; diff --git a/packages/core/helper-plugin/lib/src/utils/getFetchClient/index.js b/packages/core/helper-plugin/lib/src/utils/getFetchClient/index.js index 2ad3cb6475..00d17e5381 100644 --- a/packages/core/helper-plugin/lib/src/utils/getFetchClient/index.js +++ b/packages/core/helper-plugin/lib/src/utils/getFetchClient/index.js @@ -1,12 +1,13 @@ -import instance from '../fetchClient'; +import fetchClient from '../fetchClient'; -function getFetchClient(defaultOptions = {}) { +const getFetchClient = (defaultOptions = {}) => { + const instance = fetchClient({ baseURL: window.strapi.backendURL }); return { get: (url, config) => instance.get(url, { ...defaultOptions, ...config }), put: (url, data, config) => instance.put(url, data, { ...defaultOptions, ...config }), post: (url, data, config) => instance.post(url, data, { ...defaultOptions, ...config }), del: (url, config) => instance.delete(url, { ...defaultOptions, ...config }), }; -} +}; export default getFetchClient;