From 94bcc8e9979733bfe051c184b68e0c8498d87b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Thu, 13 Mar 2025 22:59:23 +0100 Subject: [PATCH] update to include all possible local adresses --- server/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/app.js b/server/app.js index 22c3a6908..12fe21a1d 100644 --- a/server/app.js +++ b/server/app.js @@ -71,7 +71,8 @@ const corsOptions = { ]; if(isLocalEnvironment) { - allowedOrigins.push('http://localhost:8000', 'http://localhost:8010', /^http:\/\/192\.168\.\d+\.\d+:\d+$/); + const localNetworkRegex = /^http:\/\/(localhost|127\.0\.0\.1|10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|172\.(1[6-9]|2\d|3[0-1])\.\d+\.\d+):\d+$/; + allowedOrigins.push(localNetworkRegex); } const herokuRegex = /^https:\/\/(?:homebrewery-pr-\d+\.herokuapp\.com|naturalcrit-pr-\d+\.herokuapp\.com)$/; // Matches any Heroku app @@ -352,7 +353,7 @@ app.get('/user/:username', async (req, res, next)=>{ app.put('/api/user/rename', async (req, res)=>{ const { username, newUsername } = req.body; const ownAccount = req.account && (req.account.username == newUsername); - + if(!username || !newUsername) return res.status(400).json({ error: 'Username and newUsername are required.' }); if(!ownAccount)