refactor(web/fetchNui): fetch stub

Just a naive way to patch some common exploits.
This commit is contained in:
Linden
2025-03-18 16:55:04 +11:00
parent ff2e765b60
commit f0df7ab696

View File

@@ -9,6 +9,12 @@
* @return returnData - A promise for the data sent back by the NuiCallbacks CB argument * @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
*/ */
const fetch = window.fetch;
// @ts-expect-error
window.fetch = () => {};
// @ts-expect-error
window.XMLHttpRequest = window.fetch;
export async function fetchNui<T = any>(eventName: string, data?: any): Promise<T> { export async function fetchNui<T = any>(eventName: string, data?: any): Promise<T> {
const options = { const options = {
method: 'post', method: 'post',
@@ -23,7 +29,6 @@ export async function fetchNui<T = any>(eventName: string, data?: any): Promise<
: 'nui-frame-app'; : 'nui-frame-app';
const resp = await fetch(`https://${resourceName}/${eventName}`, options); const resp = await fetch(`https://${resourceName}/${eventName}`, options);
const respFormatted = await resp.json(); const respFormatted = await resp.json();
return respFormatted; return respFormatted;