From a5552557db190f23175578464748d6c7a1522c23 Mon Sep 17 00:00:00 2001 From: unlishema Date: Sat, 20 Sep 2025 14:16:05 -0400 Subject: [PATCH] Added discord tag for request tracking. --- dist/dev.html | 16 +++++++++++++--- dist/pages/data/version.json | 2 +- src/dev.html | 16 +++++++++++++--- src/pages/data/version.json | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dist/dev.html b/dist/dev.html index e8c6272..b0041be 100644 --- a/dist/dev.html +++ b/dist/dev.html @@ -383,14 +383,17 @@ }, QUEUE_WAIT_TIME); } - // Function to make a request to the RuneScape wiki API with caching and throttling + // Function to make a request to the RuneScape wiki API with caching, throttling, Discord tag in GET, and optional headers async function requestBucket(query, oldschool = false) { const url = new URL(`https://${oldschool ? "oldschool." : ""}runescape.wiki/api.php`); + + // Add your Discord tag as a GET parameter const params = { action: 'bucket', format: 'json', query: query, - origin: '*' // Required for CORS + origin: window.location.origin, // Required for CORS + user: 'unlishema#5238' // Discord tag in GET }; url.search = new URLSearchParams(params).toString(); @@ -414,7 +417,14 @@ return enqueueRequest(async () => { console.log(`Fetching fresh data: ${url}`); - const response = await fetch(url); + const response = await fetch(url, { + headers: { + 'X-Discord-User': 'unlishema#5238', // Optional metadata header + 'X-Website': window.location.origin, // Optional site header + 'X-Environment': 'production' // Optional environment header + } + }); + if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } diff --git a/dist/pages/data/version.json b/dist/pages/data/version.json index 9cca2ad..a674bfd 100644 --- a/dist/pages/data/version.json +++ b/dist/pages/data/version.json @@ -1,3 +1,3 @@ { - "version": "0.0.34" + "version": "0.0.35" } \ No newline at end of file diff --git a/src/dev.html b/src/dev.html index e8c6272..b0041be 100644 --- a/src/dev.html +++ b/src/dev.html @@ -383,14 +383,17 @@ }, QUEUE_WAIT_TIME); } - // Function to make a request to the RuneScape wiki API with caching and throttling + // Function to make a request to the RuneScape wiki API with caching, throttling, Discord tag in GET, and optional headers async function requestBucket(query, oldschool = false) { const url = new URL(`https://${oldschool ? "oldschool." : ""}runescape.wiki/api.php`); + + // Add your Discord tag as a GET parameter const params = { action: 'bucket', format: 'json', query: query, - origin: '*' // Required for CORS + origin: window.location.origin, // Required for CORS + user: 'unlishema#5238' // Discord tag in GET }; url.search = new URLSearchParams(params).toString(); @@ -414,7 +417,14 @@ return enqueueRequest(async () => { console.log(`Fetching fresh data: ${url}`); - const response = await fetch(url); + const response = await fetch(url, { + headers: { + 'X-Discord-User': 'unlishema#5238', // Optional metadata header + 'X-Website': window.location.origin, // Optional site header + 'X-Environment': 'production' // Optional environment header + } + }); + if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } diff --git a/src/pages/data/version.json b/src/pages/data/version.json index 9cca2ad..a674bfd 100644 --- a/src/pages/data/version.json +++ b/src/pages/data/version.json @@ -1,3 +1,3 @@ { - "version": "0.0.34" + "version": "0.0.35" } \ No newline at end of file -- 2.43.0