v1.1
This commit is contained in:
@@ -3,7 +3,9 @@ import { createRoot } from 'react-dom/client';
|
||||
import { io } from 'socket.io-client';
|
||||
import './style.css';
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000';
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '/api';
|
||||
const SOCKET_ORIGIN = import.meta.env.VITE_SOCKET_ORIGIN || window.location.origin;
|
||||
const SOCKET_PATH = import.meta.env.VITE_SOCKET_PATH || `${API_BASE}/socket.io`;
|
||||
|
||||
function shuffle(items) {
|
||||
const shuffled = [...items];
|
||||
@@ -33,7 +35,7 @@ function App() {
|
||||
const votingRoundRef = useRef(null);
|
||||
const SWIPE_THRESHOLD = 110;
|
||||
|
||||
const socket = useMemo(() => io(API_URL, { autoConnect: false }), []);
|
||||
const socket = useMemo(() => io(SOCKET_ORIGIN, { autoConnect: false, path: SOCKET_PATH }), []);
|
||||
const votedRecipeIdSet = useMemo(() => new Set(votedRecipeIds), [votedRecipeIds]);
|
||||
const orderedRecipes = useMemo(() => {
|
||||
if (session?.matchMode !== 'final_round') {
|
||||
@@ -117,7 +119,7 @@ function App() {
|
||||
setError('');
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/sessions`, {
|
||||
const response = await fetch(`${API_BASE}/sessions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: hostName || 'Host' }),
|
||||
@@ -143,7 +145,7 @@ function App() {
|
||||
setError('');
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/sessions/${code}/join`, {
|
||||
const response = await fetch(`${API_BASE}/sessions/${code}/join`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: guestName || 'Gast' }),
|
||||
|
||||
Reference in New Issue
Block a user