fix proxy

This commit is contained in:
Lee 2023-10-31 11:44:27 +00:00
parent 918da6f88b
commit 47a255e48a
7 changed files with 314 additions and 341 deletions

@ -35,11 +35,7 @@ export async function getMapData(hash: string): Promise<MapData | undefined> {
} }
const before = Date.now(); const before = Date.now();
const response = await axios.get(BEATSAVER_MAP_API.replace("%s", mapHash), { const response = await axios.get(BEATSAVER_MAP_API.replace("%s", mapHash));
headers: {
"X-Requested-With": "BeatSaber Overlay",
},
});
if (response.status === 404) { if (response.status === 404) {
return undefined; return undefined;
} }

@ -3,12 +3,7 @@ import LeaderboardType from "../../consts/LeaderboardType";
export async function getPlayerData(leaderboardType, playerId) { export async function getPlayerData(leaderboardType, playerId) {
const data = await axios.get( const data = await axios.get(
LeaderboardType[leaderboardType].ApiUrl.PlayerData.replace("%s", playerId), LeaderboardType[leaderboardType].ApiUrl.PlayerData.replace("%s", playerId)
{
headers: {
"x-requested-with": "BeatSaber Overlay",
},
}
); );
return data; return data;
} }

@ -41,12 +41,7 @@ export default async function handler(req, res) {
const before = Date.now(); const before = Date.now();
const reesponse = await axios.get( const reesponse = await axios.get(
WebsiteTypes.BeatLeader.ApiUrl.MapData.replace("%h", mapHash), WebsiteTypes.BeatLeader.ApiUrl.MapData.replace("%h", mapHash)
{
headers: {
"X-Requested-With": "BeatSaber Overlay",
},
}
); );
if (reesponse.status === 404) { if (reesponse.status === 404) {
return res.status(404).json({ return res.status(404).json({

@ -40,12 +40,7 @@ export default async function handler(req, res) {
WebsiteTypes.ScoreSaber.ApiUrl.MapData.replace("%h", mapHash).replace( WebsiteTypes.ScoreSaber.ApiUrl.MapData.replace("%h", mapHash).replace(
"%d", "%d",
diffToScoreSaberDiff(difficulty) diffToScoreSaberDiff(difficulty)
), )
{
headers: {
"X-Requested-With": "BeatSaber Overlay",
},
}
); );
if (response.status === 404) { if (response.status === 404) {
return res.status(404).json({ return res.status(404).json({

@ -30,11 +30,7 @@ export const usePlayerDataStore = create<PlayerDataState>()((set) => ({
const apiUrl = Utils.getWebsiteApi( const apiUrl = Utils.getWebsiteApi(
leaderboardType leaderboardType
).ApiUrl.PlayerData.replace("%s", playerId); ).ApiUrl.PlayerData.replace("%s", playerId);
const response = await axios.get(apiUrl, { const response = await axios.get(apiUrl);
headers: {
"x-requested-with": "BeatSaber Overlay",
},
});
if (response.status !== 200) { if (response.status !== 200) {
return; return;
} }

@ -20,11 +20,7 @@ export default class Utils {
} }
static async isLeaderboardValid(url, steamId) { static async isLeaderboardValid(url, steamId) {
const response = await axios.get(url.replace("%s", steamId), { const response = await axios.get(url.replace("%s", steamId));
headers: {
"X-Requested-With": "BeatSaber Overlay",
},
});
if (response.status === 429) { if (response.status === 429) {
return true; // Just assume it's true is we are rate limited return true; // Just assume it's true is we are rate limited
} }