diff --git a/.env b/.env index e81c3999..4b96a475 100644 --- a/.env +++ b/.env @@ -13,8 +13,10 @@ #URL NGINX_ENVSUBST_TEMPLATE_SUFFIX=".conf" -BASE_URL=http://localhost - +# BASE_URL=http://localhost +BASE_URL=92.143.191.152 +REACT_APP_BASE_URL=92.143.191.152 +REDIRECT_URI=http://92.143.191.152/api/auth/login #postgres var # POSTGRES_HOST=127.0.0.1 # DB_TYPE=postgres @@ -39,6 +41,6 @@ REACT_HOST=0.0.0.0 #auth var JWT_SECRET=secrethere -REDIRECT_URI=http://localhost:80/api/auth/login +# REDIRECT_URI=http://localhost:80/api/auth/login API_SECRET=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 CLIENT_UID=u-s4t2ud-6d29dfa49ba7146577ffd8bf595ae8d9e5aaa3e0a9615df18777171ebf836a41 \ No newline at end of file diff --git a/containers/api/src/app.controller.ts b/containers/api/src/app.controller.ts index e48629d5..14046904 100644 --- a/containers/api/src/app.controller.ts +++ b/containers/api/src/app.controller.ts @@ -289,7 +289,7 @@ export class AppController { -@Redirect('http://localhost/token', 302) +@Redirect('http://' + process.env.BASE_URL + '/token', 302) @Get('auth/login') async login2(@Req() request: Request) { const url = request.url; @@ -307,7 +307,7 @@ export class AppController { const token = (await data).access_token; // console await this.userService.save(user); - return { url: `http://localhost/token?data=${encodeURIComponent(JSON.stringify(token))}` }; + return { url: 'http://' + process.env.BASE_URL + `/token?data=${encodeURIComponent(JSON.stringify(token))}` }; } @UseGuards(JwtAuthGuard) diff --git a/containers/api/src/auth/login42.ts b/containers/api/src/auth/login42.ts index da09b7f3..8f44f2e4 100644 --- a/containers/api/src/auth/login42.ts +++ b/containers/api/src/auth/login42.ts @@ -28,7 +28,7 @@ export class loginClass { // client_secret: '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', client_secret: process.env.API_SECRET, code: code, - redirect_uri: process.env.REDIRECT_URI || 'http://localhost:80/api/auth/login', + redirect_uri: process.env.REDIRECT_URI || 'http://' + process.env.REACT_APP_BASE_URL + '/api/auth/login', }; try { diff --git a/containers/react/.env b/containers/react/.env new file mode 100644 index 00000000..164f6aa7 --- /dev/null +++ b/containers/react/.env @@ -0,0 +1,2 @@ +REACT_APP_BASE_URL=92.143.191.152 +# REACT_APP_BASE_URL=192.168.1.19 \ No newline at end of file diff --git a/containers/react/src/components/App.jsx b/containers/react/src/components/App.jsx index 27d570b3..7308c286 100644 --- a/containers/react/src/components/App.jsx +++ b/containers/react/src/components/App.jsx @@ -30,8 +30,8 @@ function AnimatedRoute () { }/> }/> - } /> - } /> + {/* } /> */} + {/* } /> */} ) diff --git a/containers/react/src/components/Messages/Chats.jsx b/containers/react/src/components/Messages/Chats.jsx index 87b29cbf..286c46ee 100644 --- a/containers/react/src/components/Messages/Chats.jsx +++ b/containers/react/src/components/Messages/Chats.jsx @@ -104,7 +104,7 @@ function Chats(){ // console.log(`user= ${tmpUser.data.username}`); // console.log(`user= ${tmpUser.data.nickname}`); // console.log(`user= ${tmpUser.data}`); - socket.current = io("ws://localhost:4001"); + socket.current = io('http://' + process.env.REACT_APP_BASE_URL + ':4001'); console.log(`connection....`); socket.current.emit('connection', {username: tmpUser.data.username}) // const socket = io("http://localhost:4001", { diff --git a/containers/react/src/components/Profile/Logout.jsx b/containers/react/src/components/Profile/Logout.jsx index dd422844..029078d5 100644 --- a/containers/react/src/components/Profile/Logout.jsx +++ b/containers/react/src/components/Profile/Logout.jsx @@ -4,7 +4,7 @@ function Logout(){ localStorage.clear(); - const path = `http://localhost/`; + const path = 'http://' + process.env.REACT_APP_BASE_URL + '/'; // history(path, { replace: true }); // window.location.replace(path); // window.history.pushState({}, '', path); diff --git a/containers/react/src/components/Social/Friend.jsx b/containers/react/src/components/Social/Friend.jsx index 8630f8c1..8627b503 100644 --- a/containers/react/src/components/Social/Friend.jsx +++ b/containers/react/src/components/Social/Friend.jsx @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/09 08:18:58 by apommier #+# #+# */ -/* Updated: 2023/06/09 08:35:21 by apommier ### ########.fr */ +/* Updated: 2023/06/15 19:05:14 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,7 +79,8 @@ export default function Friend({currentUser}) }; const handleButtonClick = (user) => { - let path = `http://localhost/profile/${user.username}`; + let path = `http://` + process.env.REACT_APP_BASE_URL + `/profile/${user.username}`; + console.log("path= ", path) // history(path, { replace: true }); // window.location.replace(path); window.history.pushState({}, null, path); diff --git a/containers/react/src/components/Social/FriendRequest.jsx b/containers/react/src/components/Social/FriendRequest.jsx index 7db7f0bd..5f2f7c8a 100644 --- a/containers/react/src/components/Social/FriendRequest.jsx +++ b/containers/react/src/components/Social/FriendRequest.jsx @@ -53,7 +53,7 @@ export default function Friend({currentUser}) }, [clickEvent]) const handleButtonClick = (user) => { - let path = `http://localhost/profile/${user.username}`; + let path = `http://` + process.env.REACT_APP_BASE_URL + `/profile/${user.username}`; // history(path, { replace: true }); // window.location.replace(path); window.history.pushState({}, null, path); diff --git a/containers/react/src/pages/Home.js b/containers/react/src/pages/Home.js index 5273ff21..62cee02d 100644 --- a/containers/react/src/pages/Home.js +++ b/containers/react/src/pages/Home.js @@ -26,7 +26,8 @@ function HomeLogin() return ; } // else - let path = "https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-6d29dfa49ba7146577ffd8bf595ae8d9e5aaa3e0a9615df18777171ebf836a41&redirect_uri=http%3A%2F%2Flocalhost%3A80%2Fapi%2Fauth%2Flogin&response_type=code"; + // let path = "https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-6d29dfa49ba7146577ffd8bf595ae8d9e5aaa3e0a9615df18777171ebf836a41&redirect_uri=http%3A%2F%2F" + process.env.REACT_APP_BASE_URL + "%3A80%2Fapi%2Fauth%2Flogin&response_type=code"; + let path = "https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-6d29dfa49ba7146577ffd8bf595ae8d9e5aaa3e0a9615df18777171ebf836a41&redirect_uri=http%3A%2F%2F92.143.191.152%2Fapi%2Fauth%2Flogin&response_type=code" window.location.replace(path); }; diff --git a/containers/react/src/pages/canvas.js b/containers/react/src/pages/canvas.js index ae4785ff..a928bd43 100644 --- a/containers/react/src/pages/canvas.js +++ b/containers/react/src/pages/canvas.js @@ -25,7 +25,7 @@ function DrawCanvas(option) { // const socketRef = useRef(null); // socketRef.current = io('http://localhost:4000'); - const socket = io('http://localhost:4000'); + const socket = io('http://' + process.env.REACT_APP_BASE_URL + ':4000'); // const socket = socketRef.current console.log("start function"); const canvas = document.getElementById('myCanvas'); @@ -362,7 +362,7 @@ matchmaking(); function draw(timestamp) { - console.log("send loose"); + console.log("turning"); if (!running) return ; if (gameId === 0 ) @@ -390,7 +390,7 @@ function draw(timestamp) api.post('/status', {status: 1}); console.log("send loose"); } - window.location.replace("http://localhost/pong"); + window.location.replace("http://" + process.env.REACT_APP_BASE_URL + "/pong"); return ; } diff --git a/containers/react/src/script/axiosApi.js b/containers/react/src/script/axiosApi.js index bf7dbbb5..8a9c80b9 100644 --- a/containers/react/src/script/axiosApi.js +++ b/containers/react/src/script/axiosApi.js @@ -12,8 +12,17 @@ function getToken() { console.log(`getToken = ${getToken()}`) console.log(`Bearer ${localStorage.getItem("token")}`) +const test = "192.168.1.19" +// const url = 'http://' + process.env.REACT_APP_BASE_URL + '/api' +// const url = 'http://' + test + '/api' + +// console.log("url= ", url) +console.log("test= ", test) +console.log("env= ", process.env.REACT_APP_BASE_URL) + let api = axios.create({ - baseURL: 'http://localhost/api', +// baseURL: 'http://localhost/api', +baseURL: 'http://' + process.env.REACT_APP_BASE_URL + '/api', headers: { // Authorization: `Bearer ${getToken()}`, Authorization : `Bearer ${localStorage.getItem("token")}` diff --git a/containers/react/src/script/tokenSuccess.js b/containers/react/src/script/tokenSuccess.js index 87686fca..e8756513 100644 --- a/containers/react/src/script/tokenSuccess.js +++ b/containers/react/src/script/tokenSuccess.js @@ -7,7 +7,7 @@ function SuccessToken() { const cleanData = data.slice(1, -1); localStorage.setItem('token', `${cleanData}`); console.log(`prout token2= ${localStorage.getItem('token')}`) - window.location.replace("http://localhost/pong"); + window.location.replace("http://" + process.env.REACT_APP_BASE_URL + "/pong"); } export default SuccessToken; \ No newline at end of file diff --git a/containers/test b/containers/test new file mode 100644 index 00000000..f7eced04 --- /dev/null +++ b/containers/test @@ -0,0 +1,2 @@ +cc toi +cc 2 \ No newline at end of file