Make changes for reverse proxy stuff

This commit is contained in:
Stedoss 2025-05-14 19:03:27 +01:00
parent e91fa6dad2
commit a2acb0cc52
4 changed files with 7 additions and 3 deletions

View File

@ -18,9 +18,12 @@ export function App() {
}
useEffect(() => {
// We might be beind a reverse proxy - remove the proxied URL
const path = location.pathname.replace("/replay-viewer", "");
// This pattern matches one or more digits followed by an optional slash and any characters (non-greedy)
const pathRegex = /^\/(\d+)(?:\/(\d+))?/;
const match = location.pathname.match(pathRegex);
const match = path.match(pathRegex);
if (match) {
// match[1] will contain the first ID, match[2] (if present) will contain the second ID

View File

@ -39,7 +39,7 @@ export class Drawer {
static async loadDefaultImages() {
const imageLoadPromises = Object.keys(Drawer.images).map(imageName =>
loadImageAsync(`/${imageName}.png`).then(
loadImageAsync(`/replay-viewer/${imageName}.png`).then(
image => {
Drawer.images[imageName as keyof typeof Drawer.images] = image;
},

View File

@ -231,7 +231,7 @@ export class OsuRenderer {
static getApiUrl(): string {
return document.location.hostname === "localhost"
? `http://localhost:8080`
: `https://nise.moe/api`;
: `https://nise.stedos.dev/api`;
}
static async loadReplayPairFromUrl(replayId1: number, replayId2: number) {

View File

@ -9,4 +9,5 @@ export default defineConfig({
"@": path.resolve(__dirname, "./src"),
},
},
base: "/replay-viewer/",
});