mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
Utilisation variables d'env
This commit is contained in:
@@ -2,6 +2,8 @@ import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import SocketProvider from "@/context/socketContext";
|
||||
|
||||
import { PublicEnvScript } from 'next-runtime-env';
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export const metadata = {
|
||||
@@ -11,6 +13,9 @@ export const metadata = {
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<PublicEnvScript />
|
||||
</head>
|
||||
<SocketProvider>
|
||||
<body className={inter.className + " h-screen"}>{children}</body>
|
||||
</SocketProvider>
|
||||
|
||||
@@ -4,6 +4,8 @@ import BlueButton, { RedButton } from '../util/button';
|
||||
import useAdmin from '@/hook/useAdmin';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
import { env } from 'next-runtime-env';
|
||||
|
||||
const CircularAreaPicker = dynamic(() => import('./mapPicker').then((mod) => mod.CircularAreaPicker), {
|
||||
ssr: false
|
||||
});
|
||||
@@ -13,11 +15,12 @@ export default function TeamEdit({ selectedTeamId, setSelectedTeamId }) {
|
||||
const [newTeamName, setNewTeamName] = React.useState('');
|
||||
const { updateTeam, getTeamName, removeTeam, getTeam, teams } = useAdmin();
|
||||
const [team, setTeam] = useState({});
|
||||
const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST");
|
||||
var protocol = "https://";
|
||||
if (process.env.NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
if (NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
protocol = "http://";
|
||||
}
|
||||
const SERVER_URL = protocol + process.env.NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
const SERVER_URL = protocol + NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
console.log(SERVER_URL);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -3,6 +3,8 @@ import { RedButton } from "../util/button";
|
||||
import { useEffect, useRef } from "react";
|
||||
import Image from "next/image";
|
||||
|
||||
import { env } from 'next-runtime-env';
|
||||
|
||||
export function EnemyTeamModal({ visible, onClose }) {
|
||||
const { teamId, enemyName } = useGame();
|
||||
const imageRef = useRef(null);
|
||||
@@ -18,10 +20,11 @@ export function EnemyTeamModal({ visible, onClose }) {
|
||||
}
|
||||
|
||||
var protocol = "https://";
|
||||
if (process.env.NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST");
|
||||
if (NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
protocol = "http://";
|
||||
}
|
||||
const SERVER_URL = protocol + process.env.NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
const SERVER_URL = protocol + NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
console.log(SERVER_URL);
|
||||
return (visible &&
|
||||
<>
|
||||
|
||||
@@ -4,15 +4,18 @@ import { useRef } from "react";
|
||||
import Image from "next/image";
|
||||
import { useTeamContext } from "@/context/teamContext";
|
||||
|
||||
import { env } from 'next-runtime-env';
|
||||
|
||||
export function WaitingScreen() {
|
||||
const { name, teamId } = useGame();
|
||||
const { gameSettings } = useTeamContext();
|
||||
const imageRef = useRef(null);
|
||||
const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST");
|
||||
var protocol = "https://";
|
||||
if (process.env.NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
if (NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
protocol = "http://";
|
||||
}
|
||||
const SERVER_URL = protocol + process.env.NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
const SERVER_URL = protocol + NEXT_PUBLIC_SOCKET_HOST + "/back";
|
||||
console.log(SERVER_URL);
|
||||
|
||||
function sendImage() {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
"use client";
|
||||
import { createContext, useContext, useMemo } from "react";
|
||||
|
||||
import { env } from 'next-runtime-env';
|
||||
|
||||
const { io } = require("socket.io-client");
|
||||
|
||||
var proto = "wss://";
|
||||
if (process.env.NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST");
|
||||
if (NEXT_PUBLIC_SOCKET_HOST == "localhost") {
|
||||
proto = "ws://";
|
||||
}
|
||||
const SOCKET_URL = proto + process.env.NEXT_PUBLIC_SOCKET_HOST;
|
||||
const SOCKET_URL = proto + NEXT_PUBLIC_SOCKET_HOST;
|
||||
const USER_SOCKET_URL = SOCKET_URL + "/player";
|
||||
const ADMIN_SOCKET_URL = SOCKET_URL + "/admin";
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"@hello-pangea/dnd": "^16.6.0",
|
||||
"leaflet-defaulticon-compatibility": "^0.1.2",
|
||||
"next": "^14.2.9",
|
||||
"next-runtime-env": "^3.2.2",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"react-leaflet": "^4.2.1",
|
||||
|
||||
Reference in New Issue
Block a user