Fix login issue
This commit is contained in:
parent
bb74d0bc9d
commit
1e30df046c
@ -1,41 +0,0 @@
|
|||||||
FROM ubuntu:noble
|
|
||||||
|
|
||||||
RUN apt-get -q update \
|
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
|
||||||
ca-certificates curl gnupg \
|
|
||||||
curl \
|
|
||||||
nano \
|
|
||||||
sqlite3 \
|
|
||||||
psmisc \
|
|
||||||
wget \
|
|
||||||
jq \
|
|
||||||
less \
|
|
||||||
git \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
|
||||||
RUN mkdir -p /etc/apt/keyrings
|
|
||||||
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
||||||
|
|
||||||
# https://nodejs.org/en/about/previous-releases
|
|
||||||
ENV NODE_MAJOR=24
|
|
||||||
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
||||||
|
|
||||||
RUN apt-get -q update \
|
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
|
||||||
nodejs \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
|
||||||
|
|
||||||
COPY /client /client
|
|
||||||
WORKDIR /client
|
|
||||||
|
|
||||||
# Set environment variable for production mode (default: development)
|
|
||||||
ENV PRODUCTION=false
|
|
||||||
|
|
||||||
# Disable HTTPS by default for npm development server
|
|
||||||
ENV HTTPS=false
|
|
||||||
|
|
||||||
COPY ./client/entrypoint.sh /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
|
@ -78,10 +78,10 @@ const newLobby = await sessionsApi.createLobby("session-id", lobbyRequest);
|
|||||||
docker compose exec server uv run python3 generate_schema_simple.py
|
docker compose exec server uv run python3 generate_schema_simple.py
|
||||||
|
|
||||||
# Generate TypeScript types
|
# Generate TypeScript types
|
||||||
docker compose exec static-frontend npx openapi-typescript openapi-schema.json -o src/api-types.ts
|
docker compose exec client npx openapi-typescript openapi-schema.json -o src/api-types.ts
|
||||||
|
|
||||||
# Type check
|
# Type check
|
||||||
docker compose exec static-frontend npm run type-check
|
docker compose exec client npm run type-check
|
||||||
```
|
```
|
||||||
|
|
||||||
### Automated Generation
|
### Automated Generation
|
||||||
@ -143,8 +143,8 @@ client/
|
|||||||
If the frontend container has dependency conflicts:
|
If the frontend container has dependency conflicts:
|
||||||
```bash
|
```bash
|
||||||
# Rebuild the frontend container
|
# Rebuild the frontend container
|
||||||
docker compose build static-frontend
|
docker compose build client
|
||||||
docker compose up -d static-frontend
|
docker compose up -d client
|
||||||
```
|
```
|
||||||
|
|
||||||
### TypeScript Errors
|
### TypeScript Errors
|
||||||
|
@ -18,13 +18,13 @@ if [ ! -f "client/openapi-schema.json" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the frontend container is running
|
# Check if the frontend container is running
|
||||||
if ! docker compose ps static-frontend | grep -q "Up"; then
|
if ! docker compose ps client | grep -q "Up"; then
|
||||||
echo "📋 Starting frontend container..."
|
echo "📋 Starting frontend container..."
|
||||||
docker compose up -d static-frontend
|
docker compose up -d client
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📋 Running API evolution check..."
|
echo "📋 Running API evolution check..."
|
||||||
docker compose exec static-frontend node check-api-evolution.js
|
docker compose exec client node check-api-evolution.js
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "💡 To regenerate types and schema: ./generate-ts-types.sh"
|
echo "💡 To regenerate types and schema: ./generate-ts-types.sh"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect, KeyboardEvent, useCallback } from "react";
|
import React, { useState, useEffect, KeyboardEvent, useCallback } from "react";
|
||||||
import { Input, Paper, Typography } from "@mui/material";
|
import { Input, Paper, Typography } from "@mui/material";
|
||||||
|
|
||||||
import { Session } from "./GlobalContext";
|
import { Session, Lobby } from "./GlobalContext";
|
||||||
import { UserList } from "./UserList";
|
import { UserList } from "./UserList";
|
||||||
import { LobbyChat } from "./LobbyChat";
|
import { LobbyChat } from "./LobbyChat";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
@ -19,12 +19,6 @@ type LobbyProps = {
|
|||||||
setError: React.Dispatch<React.SetStateAction<string | null>>;
|
setError: React.Dispatch<React.SetStateAction<string | null>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Lobby = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
private: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
||||||
const { session, setSession, setError } = props;
|
const { session, setSession, setError } = props;
|
||||||
const { lobbyName = "default" } = useParams<{ lobbyName: string }>();
|
const { lobbyName = "default" } = useParams<{ lobbyName: string }>();
|
||||||
@ -35,18 +29,14 @@ const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
|||||||
const [creatingLobby, setCreatingLobby] = useState<boolean>(false);
|
const [creatingLobby, setCreatingLobby] = useState<boolean>(false);
|
||||||
const [reconnectAttempt, setReconnectAttempt] = useState<number>(0);
|
const [reconnectAttempt, setReconnectAttempt] = useState<number>(0);
|
||||||
|
|
||||||
const {
|
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
|
||||||
sendJsonMessage,
|
|
||||||
lastJsonMessage,
|
|
||||||
readyState
|
|
||||||
} = useWebSocket(socketUrl, {
|
|
||||||
onOpen: () => {
|
onOpen: () => {
|
||||||
console.log("app - WebSocket connection opened.");
|
console.log("app - WebSocket connection opened.");
|
||||||
setReconnectAttempt(0);
|
setReconnectAttempt(0);
|
||||||
},
|
},
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
console.log("app - WebSocket connection closed.");
|
console.log("app - WebSocket connection closed.");
|
||||||
setReconnectAttempt(prev => prev + 1);
|
setReconnectAttempt((prev) => prev + 1);
|
||||||
},
|
},
|
||||||
onError: (event: Event) => console.error("app - WebSocket error observed:", event),
|
onError: (event: Event) => console.error("app - WebSocket error observed:", event),
|
||||||
shouldReconnect: (closeEvent) => true, // Will attempt to reconnect on all close events
|
shouldReconnect: (closeEvent) => true, // Will attempt to reconnect on all close events
|
||||||
@ -69,10 +59,10 @@ const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
|||||||
}
|
}
|
||||||
const data: any = lastJsonMessage;
|
const data: any = lastJsonMessage;
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "update":
|
case "update_name":
|
||||||
if ("name" in data) {
|
if (data.data && "name" in data.data) {
|
||||||
console.log(`Lobby - name set to ${data.name}`);
|
console.log(`Lobby - name set to ${data.data.name}`);
|
||||||
setSession((s) => (s ? { ...s, name: data.name } : null));
|
setSession((s) => (s ? { ...s, name: data.data.name } : null));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
|
type Lobby = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
private: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
type Session = {
|
type Session = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
lobbies: string[];
|
lobbies: Lobby[];
|
||||||
};
|
};
|
||||||
export type { Session };
|
|
||||||
|
export type { Session, Lobby };
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
services:
|
services:
|
||||||
static-frontend:
|
client:
|
||||||
container_name: static-frontend
|
container_name: client
|
||||||
hostname: static-frontend
|
hostname: client
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.frontend
|
dockerfile: Dockerfile.client
|
||||||
env_file:
|
env_file:
|
||||||
- ./.env
|
- ./.env
|
||||||
environment:
|
environment:
|
||||||
|
@ -16,19 +16,19 @@ echo "📋 Step 1: Generating OpenAPI schema from FastAPI server..."
|
|||||||
docker compose exec server uv run python3 generate_schema_simple.py
|
docker compose exec server uv run python3 generate_schema_simple.py
|
||||||
|
|
||||||
echo "📋 Step 2: Ensuring frontend container is running..."
|
echo "📋 Step 2: Ensuring frontend container is running..."
|
||||||
docker compose up -d static-frontend
|
docker compose up -d client
|
||||||
|
|
||||||
echo "📋 Step 3: Installing/updating frontend dependencies..."
|
echo "📋 Step 3: Installing/updating frontend dependencies..."
|
||||||
docker compose exec static-frontend npm install --legacy-peer-deps
|
docker compose exec client npm install --legacy-peer-deps
|
||||||
|
|
||||||
echo "📋 Step 4: Generating TypeScript types from OpenAPI schema..."
|
echo "📋 Step 4: Generating TypeScript types from OpenAPI schema..."
|
||||||
docker compose exec static-frontend npx openapi-typescript openapi-schema.json -o src/api-types.ts
|
docker compose exec client npx openapi-typescript openapi-schema.json -o src/api-types.ts
|
||||||
|
|
||||||
echo "📋 Step 5: Running TypeScript type checking..."
|
echo "📋 Step 5: Running TypeScript type checking..."
|
||||||
docker compose exec static-frontend npm run type-check
|
docker compose exec client npm run type-check
|
||||||
|
|
||||||
echo "📋 Step 6: Running API evolution check..."
|
echo "📋 Step 6: Running API evolution check..."
|
||||||
docker compose exec static-frontend node check-api-evolution.js
|
docker compose exec client node check-api-evolution.js
|
||||||
|
|
||||||
echo "✅ TypeScript generation complete!"
|
echo "✅ TypeScript generation complete!"
|
||||||
echo "📄 Generated files:"
|
echo "📄 Generated files:"
|
||||||
|
@ -1233,7 +1233,7 @@ if PRODUCTION:
|
|||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.info(f"Proxying static files to http://static-frontend:3000 at {public_url}")
|
logger.info(f"Proxying static files to http://client:3000 at {public_url}")
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
@ -1245,9 +1245,9 @@ else:
|
|||||||
# Do not proxy API or websocket paths
|
# Do not proxy API or websocket paths
|
||||||
if path.startswith("api/") or path.startswith("ws/"):
|
if path.startswith("api/") or path.startswith("ws/"):
|
||||||
return Response(status_code=404)
|
return Response(status_code=404)
|
||||||
url = f"{request.url.scheme}://static-frontend:3000/{public_url.strip('/')}/{path}"
|
url = f"{request.url.scheme}://client:3000/{public_url.strip('/')}/{path}"
|
||||||
if not path:
|
if not path:
|
||||||
url = f"{request.url.scheme}://static-frontend:3000/{public_url.strip('/')}"
|
url = f"{request.url.scheme}://client:3000/{public_url.strip('/')}"
|
||||||
headers = dict(request.headers)
|
headers = dict(request.headers)
|
||||||
try:
|
try:
|
||||||
# Accept self-signed certs in dev
|
# Accept self-signed certs in dev
|
||||||
@ -1284,7 +1284,7 @@ else:
|
|||||||
logger.info("REACT: WebSocket proxy connection established.")
|
logger.info("REACT: WebSocket proxy connection established.")
|
||||||
# Get scheme from websocket.url (should be 'ws' or 'wss')
|
# Get scheme from websocket.url (should be 'ws' or 'wss')
|
||||||
scheme = websocket.url.scheme if hasattr(websocket, "url") else "ws"
|
scheme = websocket.url.scheme if hasattr(websocket, "url") else "ws"
|
||||||
target_url = f"{scheme}://static-frontend:3000/ws"
|
target_url = f"{scheme}://client:3000/ws"
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
try:
|
try:
|
||||||
# Accept self-signed certs in dev for WSS
|
# Accept self-signed certs in dev for WSS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user