mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
refactor(web/fetchNui): fetch stub
Just a naive way to patch some common exploits.
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user