fix: handle same-origin deployments in postMessage validation
Fall back to window.location.origin when baseUrl is empty or relative, supporting same-origin deployments while maintaining origin validation.
This commit is contained in:
@@ -44,12 +44,14 @@ const updateAuthCookie = (cookieContent, baseDomain = '') =>
|
||||
|
||||
const getTargetOrigin = () => {
|
||||
const { baseUrl } = window.$chatwoot || {};
|
||||
if (!baseUrl) return null;
|
||||
if (!baseUrl) {
|
||||
return window.location.origin;
|
||||
}
|
||||
try {
|
||||
const url = new URL(baseUrl);
|
||||
return url.origin;
|
||||
} catch {
|
||||
return null;
|
||||
return window.location.origin;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user