From 72fc763101feddf92b05c622188ac23b0d64e54b Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 2 Oct 2026 01:13:27 +0000 Subject: [PATCH] Prepare Airship frontend for ChatGPT Sites portability test --- .env.example | 5 +++++ SITES.md | 27 +++++++++++++++++++++++++++ src/multiplayer.js | 11 ++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100644 SITES.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9e97d3e --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +VITE_AIRSHIP_API_BASE=https://game.arrowstack.dev +VITE_AIRSHIP_WS_BASE=wss://game.arrowstack.dev +VITE_KEYCLOAK_URL=https://auth.arrowstack.dev +VITE_KEYCLOAK_REALM=dev +VITE_KEYCLOAK_CLIENT_ID=airship-web diff --git a/SITES.md b/SITES.md new file mode 100644 index 0000000..36b1f68 --- /dev/null +++ b/SITES.md @@ -0,0 +1,27 @@ +# ChatGPT Sites portability test + +This branch keeps ChatGPT Sites at the presentation boundary only. + +## Ownership boundary + +- Sites: built Phaser/Vite frontend and static assets. +- Arrowstack: Keycloak identity, API, authoritative multiplayer simulation, PostgreSQL state, and WebSocket transport. + +The browser defaults still point to: + +- API: https://game.arrowstack.dev +- WebSocket: wss://game.arrowstack.dev +- Identity: https://auth.arrowstack.dev, realm `dev`, client `airship-web` + +They can be overridden with the Vite variables in `.env.example`. + +## First deployment + +Ask Sites to build this existing Vite project without moving the Go server or game state into Sites. + +Once Sites returns its production origin, add that exact HTTPS origin to: + +1. the Airship Go server `ALLOWED_ORIGINS` value, and +2. the Keycloak `airship-web` client's redirect URIs and web origins. + +Until those origin allow-lists are updated, the game should still render and remain usable in solo mode; authenticated multiplayer is expected to fail closed. diff --git a/src/multiplayer.js b/src/multiplayer.js index a23f016..8558537 100644 --- a/src/multiplayer.js +++ b/src/multiplayer.js @@ -1,11 +1,12 @@ import Keycloak from 'keycloak-js'; -const API_BASE = 'https://game.arrowstack.dev'; -const WS_BASE = 'wss://game.arrowstack.dev'; +const env = import.meta.env || {}; +const API_BASE = env.VITE_AIRSHIP_API_BASE || 'https://game.arrowstack.dev'; +const WS_BASE = env.VITE_AIRSHIP_WS_BASE || 'wss://game.arrowstack.dev'; const KEYCLOAK_CONFIG = { - url: 'https://auth.arrowstack.dev', - realm: 'dev', - clientId: 'airship-web', + url: env.VITE_KEYCLOAK_URL || 'https://auth.arrowstack.dev', + realm: env.VITE_KEYCLOAK_REALM || 'dev', + clientId: env.VITE_KEYCLOAK_CLIENT_ID || 'airship-web', }; const clamp = (value, min, max) => Math.max(min, Math.min(max, value));