Index: pages/api/blackjack/index.js
===================================================================
--- pages/api/blackjack/index.js	(revision ebf5e04ad50c2ebbd0adf24c814a57cae1a7a172)
+++ pages/api/blackjack/index.js	(revision 285c3cc6d8962d6a01d8b88f202814829bd63d98)
@@ -255,16 +255,21 @@
         }
 
-        const room = rooms[session_id];
-
-        room.sideBet = parseInt(req.query.bet);
-        room.sideBetName = req.query.betName;
-        room.status = '_3_made_side_bet';
-
-        rooms[session_id] = room;
-
-        res.json({
-          success: true,
-          status: rooms[session_id].status,
-        })
+        axios.get(`${process.env.HOME_URL}/api/postgre?action=take_credits&session_id=${session_id}&credits=${req.query.bet}`).then(postgreRes => {
+          if (postgreRes.data?.success) {
+            const room = rooms[session_id];
+
+            room.sideBet = parseInt(req.query.bet);
+            room.sideBetName = req.query.betName;
+            room.status = '_3_made_side_bet';
+
+            rooms[session_id] = room;
+
+            res.json({
+              success: true,
+              status: rooms[session_id].status,
+              credits: postgreRes.data?.credits,
+            })
+          }
+        });
         
         return ;
@@ -289,15 +294,25 @@
         if (parseInt(req.query.bet) <= 0) return ;
 
-        const room = rooms[session_id];
-
-        room.initialBet = parseInt(req.query.bet);
-        room.status = '_2_made_initial_bet';
-
-        rooms[session_id] = room;
-
-        res.json({
-          success: true,
-          status: rooms[session_id].status,
-        })
+        axios.get(`${process.env.HOME_URL}/api/postgre?action=take_credits&session_id=${session_id}&credits=${req.query.bet}`).then(postgreRes => {
+          if (postgreRes.data?.success) {
+            const room = rooms[session_id];
+
+            room.initialBet = parseInt(req.query.bet);
+            room.status = '_2_made_initial_bet';
+
+            rooms[session_id] = room;
+
+            res.json({
+              success: true,
+              status: rooms[session_id].status,
+              credits: postgreRes.data?.credits,
+            })
+          }
+          else {
+            res.json({
+              success: false,
+            })
+          }
+        });
 
         return ;
@@ -337,37 +352,49 @@
       const session_id = req.query.session_id;
 
-      if (rooms[session_id] !== undefined) {
-
-      }
-      else {
-        createARoom(session_id);
-      }
-
-      let dealerCardsTmp = [];
-      if (rooms[session_id].status.substr(1, 1) != '5') { // 5 == game_over
-        rooms[session_id].dealerCards.forEach((card, i) => {
-          if (i === 0) {
-            dealerCardsTmp.push(card);
+      axios.get(`${process.env.HOME_URL}/api/postgre?action=check_if_logged_in&session_id=${session_id}`).then(postgreRes => {
+        if (postgreRes.data?.success) {
+          if (rooms[session_id] !== undefined) {
+            // room exists
           }
           else {
-            dealerCardsTmp.push('back');
-          }
-        })
-      }
-      else {
-        dealerCardsTmp = rooms[session_id].dealerCards;
-      }
-
-      res.json({
-        success: true,
-        status: rooms[session_id].status,
-        initialBet: rooms[session_id].initialBet,
-        sideBet: rooms[session_id].sideBet,
-        sideBetName: rooms[session_id].sideBetName,
-        playerCards: rooms[session_id].playerCards,
-        dealerCards: dealerCardsTmp,
-        outcome: rooms[session_id].outcome,
-        earnings: rooms[session_id].earnings,
-      })
+            createARoom(session_id);
+          }
+    
+          let dealerCardsTmp = [];
+          if (rooms[session_id].status.substr(1, 1) != '5') { // 5 == game_over
+            rooms[session_id].dealerCards.forEach((card, i) => {
+              if (i === 0) {
+                dealerCardsTmp.push(card);
+              }
+              else {
+                dealerCardsTmp.push('back');
+              }
+            })
+          }
+          else {
+            dealerCardsTmp = rooms[session_id].dealerCards;
+          }
+    
+          res.json({
+            success: true,
+            status: rooms[session_id].status,
+            initialBet: rooms[session_id].initialBet,
+            sideBet: rooms[session_id].sideBet,
+            sideBetName: rooms[session_id].sideBetName,
+            playerCards: rooms[session_id].playerCards,
+            dealerCards: dealerCardsTmp,
+            outcome: rooms[session_id].outcome,
+            earnings: rooms[session_id].earnings,
+            displayName: postgreRes.data?.displayName,
+            session_id: postgreRes.data?.session_id,
+            credits: postgreRes.data?.credits,
+          })
+        }
+        else {
+          res.json({
+            success: false,
+          })
+        }
+      });
     }
   }
Index: pages/api/postgre/index.js
===================================================================
--- pages/api/postgre/index.js	(revision ebf5e04ad50c2ebbd0adf24c814a57cae1a7a172)
+++ pages/api/postgre/index.js	(revision 285c3cc6d8962d6a01d8b88f202814829bd63d98)
@@ -170,32 +170,5 @@
     /**
      * /---------------------- GET ----------------------/
-     * Returns the player's room, if the player was in one.
-     * Same as the one below, but this one is used in a game-specific context.
-     * @action get_player_info_on_enter
-     * @param session_id
-     */
-    if (req.query?.action === 'get_player_info_on_enter' && req.query?.session_id) {
-      const session_id = req.query.session_id
-      const session = sessions.find(session => session.id === session_id)
-
-      if (session) {
-        res.json({
-          success: true,
-          displayName: session.displayName,
-          session_id: session.id,
-          credits: session.credits,
-        })
-        return ;
-      }
-
-      res.json({
-        success: false,
-      })
-    }
-
-    /**
-     * /---------------------- GET ----------------------/
-     * Returns the player's room, if the player was in one.
-     * Same as the one above, but this one is used in a general context.
+     * Checks if the player is logged in, and returns his session if so.
      * @action check_if_logged_in
      * @param session_id
