Updated proxy

This commit is contained in:
Liam 2022-10-17 12:58:07 +01:00
parent 7c713a99ab
commit 2ff4ae7e10
4 changed files with 19 additions and 20 deletions

@ -1,8 +1,8 @@
{ {
"name": "BeatSaber Overlay", "name": "BeatSaber Overlay",
"title": "BeatSaber Overlay - Simple and easy to use BeatSaber overlay", "title": "BeatSaber Overlay - Simple and easy to use BeatSaber overlay",
"description": "Free, simple, and easy to use beat saber overlay for OBS", "description": "Free, simple, and easy to use beat saber overlay for OBS",
"color": "#0EBFE9", "color": "#0EBFE9",
"url": "https://bs-overlay.fascinated.cc", "url": "https://bs-overlay.fascinated.cc",
"proxy_url": "https://bangor375.herokuapp.com" "proxy_url": "https://proxy.fascinated.cc"
} }

@ -1,4 +1,3 @@
// 1. import `NextUIProvider` component
import { NextUIProvider } from "@nextui-org/react"; import { NextUIProvider } from "@nextui-org/react";
import { NextSeo } from "next-seo"; import { NextSeo } from "next-seo";
import Head from "next/head"; import Head from "next/head";
@ -9,7 +8,6 @@ import "../styles/globals.css";
function MyApp({ Component, pageProps }) { function MyApp({ Component, pageProps }) {
return ( return (
// 2. Use at the root of your app
<NextUIProvider> <NextUIProvider>
<NextSeo <NextSeo
title={Config.name} title={Config.name}

@ -3,8 +3,8 @@ import { Component } from "react";
import PlayerStats from "../src/components/PlayerStats"; import PlayerStats from "../src/components/PlayerStats";
import ScoreStats from "../src/components/ScoreStats"; import ScoreStats from "../src/components/ScoreStats";
import SongInfo from "../src/components/SongInfo"; import SongInfo from "../src/components/SongInfo";
import Utils from "../src/utils/utils"; import Utils from "../src/utils/utils";
import styles from "../styles/overlay.module.css"; import styles from "../styles/overlay.module.css";
export default class Overlay extends Component { export default class Overlay extends Component {
@ -12,12 +12,11 @@ export default class Overlay extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
loading: true, loading: true,
isConnectedToSocket: false, isConnectedToSocket: false,
id: undefined, id: undefined,
isValidSteamId: true, isValidSteamId: false,
websiteType: "ScoreSaber", websiteType: "ScoreSaber",
data: undefined, data: undefined,
showPlayerStats: true, showPlayerStats: true,
@ -145,11 +144,13 @@ export default class Overlay extends Component {
*/ */
async updateData(id) { async updateData(id) {
const data = await fetch( const data = await fetch(
new Utils() Utils.getWebsiteApi(
.getWebsiteApi(id == "test" ? "Test" : this.state.websiteType) id == "test" ? "Test" : this.state.websiteType
.ApiUrl.replace("%s", id), ).ApiUrl.replace("%s", id),
{ {
mode: "cors", headers: {
"X-Requested-With": "BeatSaber Overlay",
},
} }
); );
const json = await data.json(); const json = await data.json();
@ -158,7 +159,7 @@ export default class Overlay extends Component {
this.setState({ loading: false, isValidSteamId: false }); this.setState({ loading: false, isValidSteamId: false });
return; return;
} }
this.setState({ loading: false, id: id, data: json }); this.setState({ loading: false, id: id, data: json, isValidSteamId: true });
} }
/** /**
@ -183,10 +184,10 @@ export default class Overlay extends Component {
}); });
socket.addEventListener("close", () => { socket.addEventListener("close", () => {
console.log( console.log(
"Attempting to re-connect to the HTTP Status socket in 10 seconds." "Attempting to re-connect to the HTTP Status socket in 60 seconds."
); );
this.setState({ isConnectedToSocket: false }); this.setState({ isConnectedToSocket: false });
setTimeout(() => this.connectSocket(), 10_000); setTimeout(() => this.connectSocket(), 60_000);
}); });
socket.addEventListener("message", (message) => { socket.addEventListener("message", (message) => {
const json = JSON.parse(message.data); const json = JSON.parse(message.data);

@ -9,7 +9,7 @@ export default class Utils {
* @param {WebsiteTypes} website * @param {WebsiteTypes} website
* @returns The website type's information. * @returns The website type's information.
*/ */
getWebsiteApi(website) { static getWebsiteApi(website) {
return WebsiteTypes[website]; return WebsiteTypes[website];
} }
} }