20260607 - login, add scene, add hotspot
This commit is contained in:
@@ -19,9 +19,16 @@ const verifyReferer = (req, res, next) => {
|
||||
const isMatch = (headerValue) => {
|
||||
if (!headerValue) return false;
|
||||
try {
|
||||
return new URL(headerValue).origin === allowedOrigin;
|
||||
const urlObj = new URL(headerValue);
|
||||
const incomingOrigin = urlObj.origin;
|
||||
// Cho phép nếu khớp hoàn toàn origin
|
||||
if (incomingOrigin === allowedOrigin) return true;
|
||||
// Trong môi trường development, cho phép localhost với bất kỳ port nào
|
||||
const isLocal = incomingOrigin.includes('localhost') || incomingOrigin.includes('127.0.0.1') || incomingOrigin.includes('::1');
|
||||
if (process.env.NODE_ENV !== 'production' && isLocal) return true;
|
||||
return false;
|
||||
} catch (e) {
|
||||
return headerValue.startsWith(allowedOrigin);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user