Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix localStorage usage

Roman Pominov33cd902eda6a
diff --git a/apps/designer/app/entry.client.tsx b/apps/designer/app/entry.client.tsx
index af4f800575..65822500b7 100644
--- a/apps/designer/app/entry.client.tsx
+++ b/apps/designer/app/entry.client.tsx
@@ -21,12 +21,18 @@ initSentry({
// Forward DEBUG env variable defined on the server to the client-side debug() utility.
// This way you can set it once server-side and have the logging or feature flags enabled on both, server and client
-if (
- typeof localStorage !== "undefined" &&
- // Client-side value should override the server-side one
- (localStorage.debug == null || localStorage.debug === "")
-) {
- localStorage.debug = env.DEBUG;
+// https://github.com/debug-js/debug#browser-support
+try {
+ if (
+ // Client-side value should override the server-side one
+ localStorage.debug == null ||
+ localStorage.debug === ""
+ ) {
+ localStorage.debug = env.DEBUG;
+ }
+} catch (e) {
+ // eslint-disable-next-line no-console
+ console.warn("Failed to set localStorage.debug due to Error:", e);
}
hydrate(<RemixBrowser />, document);