Skip to content

Commit 2eeed45

Browse files
authored
Fix: Suppress Publift Fuse cross-origin errors
1 parent 1d0ca8d commit 2eeed45

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/components/Gam.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,50 @@ export function GamOnPageChange() {
5555

5656
export const GamScripts = () => (
5757
<>
58+
<script
59+
dangerouslySetInnerHTML={{
60+
__html: `
61+
// Add global error handler to suppress Publift Fuse cross-origin errors
62+
// These errors occur in iOS Safari due to strict Same-Origin Policy enforcement
63+
// when the ad viewability script tries to access parent window properties
64+
// Also suppress race condition errors during navigation
65+
(function() {
66+
var originalErrorHandler = window.onerror;
67+
window.onerror = function(message, source, lineno, colno, error) {
68+
// Check if this is a Publift Fuse cross-origin error
69+
if (
70+
source && (
71+
source.includes('/media/native/') ||
72+
source.includes('fuse.js') ||
73+
source.includes('fuseplatform.net') ||
74+
source.includes('/nobid/blocking_script.js')
75+
) && (
76+
(message && typeof message === 'string' && (
77+
message.includes('contextWindow.parent') ||
78+
message.includes('null is not an object') ||
79+
message.includes('is not a function')
80+
)) ||
81+
(error && error.message && (
82+
error.message.includes('contextWindow.parent') ||
83+
error.message.includes('null is not an object') ||
84+
error.message.includes('is not a function')
85+
))
86+
)
87+
) {
88+
// Suppress the error - log to console in debug mode
89+
console.debug('Suppressed Publift Fuse cross-origin error:', message, source);
90+
return true; // Prevent default error handling
91+
}
92+
// Call original error handler for other errors
93+
if (originalErrorHandler) {
94+
return originalErrorHandler.apply(this, arguments);
95+
}
96+
return false;
97+
};
98+
})();
99+
`,
100+
}}
101+
/>
58102
<script
59103
async
60104
src="https://cdn.fuseplatform.net/publift/tags/2/4019/fuse.js"

0 commit comments

Comments
 (0)