From f0df7ab696e255a0617f35acc64d2fedb55fe4f9 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:55:04 +1100 Subject: [PATCH] refactor(web/fetchNui): fetch stub Just a naive way to patch some common exploits. --- web/src/utils/fetchNui.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/utils/fetchNui.ts b/web/src/utils/fetchNui.ts index 5b3cd2d..f45f19a 100644 --- a/web/src/utils/fetchNui.ts +++ b/web/src/utils/fetchNui.ts @@ -9,6 +9,12 @@ * @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(eventName: string, data?: any): Promise { const options = { method: 'post', @@ -23,7 +29,6 @@ export async function fetchNui(eventName: string, data?: any): Promise< : 'nui-frame-app'; const resp = await fetch(`https://${resourceName}/${eventName}`, options); - const respFormatted = await resp.json(); return respFormatted;