mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 00:42:47 +00:00
Change local regex testing
This commit is contained in:
@@ -69,14 +69,11 @@ const corsOptions = {
|
|||||||
'https://homebrewery-stage.herokuapp.com',
|
'https://homebrewery-stage.herokuapp.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
if(isLocalEnvironment) {
|
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+$/;
|
||||||
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
|
const herokuRegex = /^https:\/\/(?:homebrewery-pr-\d+\.herokuapp\.com|naturalcrit-pr-\d+\.herokuapp\.com)$/; // Matches any Heroku app
|
||||||
|
|
||||||
if(!origin || allowedOrigins.includes(origin) || herokuRegex.test(origin)) {
|
if(!origin || allowedOrigins.includes(origin) || herokuRegex.test(origin) || (isLocalEnvironment && localNetworkRegex.test(origin))) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
console.log(origin, 'not allowed');
|
console.log(origin, 'not allowed');
|
||||||
|
|||||||
Reference in New Issue
Block a user