Wix enforces security restrictions in the frontend rendering environment to protect site visitors and ensure that apps and custom code operate in their granted permissions. These restrictions prevent unauthorized access to sensitive data such as access tokens and cookies, and block code from manipulating the browser environment in ways that could compromise site security.
These measures apply to all code running on the frontend of a Wix site, including custom code, site code written with the Wix JavaScript SDK, and code from installed apps.
Wix's frontend security model builds on 2 core principles: isolation and immutability.
When these protections detect an unauthorized operation, they either silently block it or throw an error with a specific error code.
Wix restricts or modifies the following browser APIs in the frontend rendering environment.
Wix actively prevents code from accessing or interfering with sensitive operations like authentication tokens and internal network requests. To do this, Wix replaces the built-in browser fetch and XMLHttpRequest implementations with secured versions. These secured versions:
window.fetch or XMLHttpRequest with a custom implementation, the reassignment has no effect.This means techniques that involve replacing or wrapping built-in browser methods to intercept network traffic don't work on Wix sites.
Wix restricts the document.cookie API. Code that attempts to read or write Wix internal cookies or security cookies fails silently. The operation has no effect, and no error is thrown.
When code calls window.open or document.open to open a new window on the same domain as the site, the returned object is empty instead of a reference to the new window. This prevents code from using the opened window to rewrite global objects or access cookies.
Wix applies the following restrictions to iframes created by frontend code:
srcdoc attribute is blocked. Attempts to set srcdoc on an iframe result in an error.Wix locks the following objects and their prototypes to prevent overwriting, extending, or manipulating their methods:
URL, JSONString, Number, Object, ReflectTextEncoder, TextDecoderencodeURIComponent, decodeURIComponentaddEventListener, removeEventListenerXMLHttpRequestEventTarget, EventTargetCode that attempts to modify these objects, or override their methods or prototypes will generally fail and throw errors.
setTimeout and setInterval don't accept a string as their first argument. This prevents dynamic code evaluation through timers.
Pass a callback instead of a string:
If your code isn't working as expected, it may be affected by frontend security restrictions. Check the browser console for errors and review the following common symptoms:
fetch or XMLHttpRequest implementations, or trying to call restricted internal URLs. Use the standard browser APIs as-is without replacing them.window.open returns an empty object: This happens when opening a window on the same domain as the site. Cross-domain windows aren't affected.postMessage for parent-child communication.URL, JSON, String, and Object can't be extended or modified.setTimeout/setInterval fails: Pass a callback instead of a string as the first argument.