Make changes for reverse proxy stuff
This commit is contained in:
parent
e91fa6dad2
commit
a2acb0cc52
@ -18,9 +18,12 @@ export function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
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)
|
// This pattern matches one or more digits followed by an optional slash and any characters (non-greedy)
|
||||||
const pathRegex = /^\/(\d+)(?:\/(\d+))?/;
|
const pathRegex = /^\/(\d+)(?:\/(\d+))?/;
|
||||||
const match = location.pathname.match(pathRegex);
|
const match = path.match(pathRegex);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
// match[1] will contain the first ID, match[2] (if present) will contain the second ID
|
// match[1] will contain the first ID, match[2] (if present) will contain the second ID
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export class Drawer {
|
|||||||
|
|
||||||
static async loadDefaultImages() {
|
static async loadDefaultImages() {
|
||||||
const imageLoadPromises = Object.keys(Drawer.images).map(imageName =>
|
const imageLoadPromises = Object.keys(Drawer.images).map(imageName =>
|
||||||
loadImageAsync(`/${imageName}.png`).then(
|
loadImageAsync(`/replay-viewer/${imageName}.png`).then(
|
||||||
image => {
|
image => {
|
||||||
Drawer.images[imageName as keyof typeof Drawer.images] = image;
|
Drawer.images[imageName as keyof typeof Drawer.images] = image;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -231,7 +231,7 @@ export class OsuRenderer {
|
|||||||
static getApiUrl(): string {
|
static getApiUrl(): string {
|
||||||
return document.location.hostname === "localhost"
|
return document.location.hostname === "localhost"
|
||||||
? `http://localhost:8080`
|
? `http://localhost:8080`
|
||||||
: `https://nise.moe/api`;
|
: `https://nise.stedos.dev/api`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async loadReplayPairFromUrl(replayId1: number, replayId2: number) {
|
static async loadReplayPairFromUrl(replayId1: number, replayId2: number) {
|
||||||
|
|||||||
@ -9,4 +9,5 @@ export default defineConfig({
|
|||||||
"@": path.resolve(__dirname, "./src"),
|
"@": path.resolve(__dirname, "./src"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
base: "/replay-viewer/",
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user