From d9727b6fcb387813d479cc6a237baecfa7246ad8 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Fri, 4 Oct 2024 20:42:52 +0200 Subject: [PATCH] Do not use resources subdomain --- apps/api/app/config/nginx | 18 ++++++++++++++++++ .../web/src/components/Game/StartedGame.svelte | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/api/app/config/nginx b/apps/api/app/config/nginx index dd830f4c..442842b5 100644 --- a/apps/api/app/config/nginx +++ b/apps/api/app/config/nginx @@ -41,6 +41,10 @@ server { try_files $uri $uri/ @proxy_game_server; } + location /resources { + try_files $uri $uri/ @resources; + } + location /api { try_files $uri $uri/ @proxy; } @@ -67,6 +71,20 @@ server { proxy_redirect off; } + location @resources { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + proxy_set_header X-Forwarded-Proto $scheme; + + // Rewrite url to remove "/resources" prefix + rewrite ^/resources/(.*) /$1 break; + + proxy_pass http://gaia_resources; + proxy_redirect off; + } + location @proxy_game_server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/apps/web/src/components/Game/StartedGame.svelte b/apps/web/src/components/Game/StartedGame.svelte index 906b2b3b..ec299cb1 100644 --- a/apps/web/src/components/Game/StartedGame.svelte +++ b/apps/web/src/components/Game/StartedGame.svelte @@ -30,7 +30,7 @@ let stateSent = false; const resourcesLink = - session.host.startsWith("localhost") || session.host.endsWith("gitpod.io") + session.host.startsWith("localhost") || session.host.endsWith("gitpod.io") || session.host === "boardgamers.space" ? `/resources` : `//resources.${session.host.slice(session.host.indexOf(".") + 1)}`; @@ -192,7 +192,7 @@ if ($game.status === "active") { title = `${gameId} - ${gameLabel($gameInfo.label)} game`; description = `Round ${$game.data.round} - + ${$game.players.map((pl) => `- ${pl.name} (${pl.score} pts)`).join("\n")}`; } else if ($game.cancelled) { title = `Cancelled - ${gameLabel($gameInfo.label)} game`;