[skip ci]Fix: modify proxy reponse url
This commit is contained in:
+5
-6
@@ -15,16 +15,15 @@ import 'protobufjs';
|
|||||||
const { fetch: originalFetch } = window;
|
const { fetch: originalFetch } = window;
|
||||||
window.fetch = async (...args) => {
|
window.fetch = async (...args) => {
|
||||||
const [resource, config] = args;
|
const [resource, config] = args;
|
||||||
if (resource.toString().includes('localhost')) {
|
const _res = await originalFetch('http://localhost:3001/' + resource, {
|
||||||
const response = await originalFetch(resource, config);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
const response = await originalFetch('http://localhost:3001/' + resource, {
|
|
||||||
...config,
|
...config,
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
});
|
});
|
||||||
return response;
|
Object.defineProperty(_res, 'url', {
|
||||||
|
value: _res.url.includes('localhost') ? resource.toString() : _res.url,
|
||||||
|
});
|
||||||
|
return _res;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
|
|||||||
Reference in New Issue
Block a user