From c322baa9c8fe49c5435bf65004a098522e4b3816 Mon Sep 17 00:00:00 2001 From: lohit Date: Wed, 20 Nov 2024 03:22:39 +0530 Subject: [PATCH] fix: server_rendered logic for newer versions of nextjs (#3509) * fix: server_rendered condition update --- packages/bruno-app/src/components/CodeEditor/index.js | 2 +- packages/bruno-app/src/components/MultiLineEditor/index.js | 2 +- .../bruno-app/src/components/RequestPane/QueryEditor/index.js | 2 +- packages/bruno-app/src/components/SingleLineEditor/index.js | 2 +- packages/bruno-app/src/pages/Bruno/index.js | 2 +- packages/bruno-app/src/pages/_app.js | 3 +-- packages/bruno-app/src/utils/common/codemirror.js | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/bruno-app/src/components/CodeEditor/index.js b/packages/bruno-app/src/components/CodeEditor/index.js index 8ec68bdf8..f0f1ed55e 100644 --- a/packages/bruno-app/src/components/CodeEditor/index.js +++ b/packages/bruno-app/src/components/CodeEditor/index.js @@ -15,7 +15,7 @@ import { JSHINT } from 'jshint'; import stripJsonComments from 'strip-json-comments'; let CodeMirror; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; const TAB_SIZE = 2; if (!SERVER_RENDERED) { diff --git a/packages/bruno-app/src/components/MultiLineEditor/index.js b/packages/bruno-app/src/components/MultiLineEditor/index.js index d548898fe..97b3eca07 100644 --- a/packages/bruno-app/src/components/MultiLineEditor/index.js +++ b/packages/bruno-app/src/components/MultiLineEditor/index.js @@ -5,7 +5,7 @@ import { defineCodeMirrorBrunoVariablesMode } from 'utils/common/codemirror'; import StyledWrapper from './StyledWrapper'; let CodeMirror; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; if (!SERVER_RENDERED) { CodeMirror = require('codemirror'); diff --git a/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js b/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js index 3d93aae8d..60bafc8fe 100644 --- a/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js +++ b/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js @@ -19,7 +19,7 @@ import { IconWand } from '@tabler/icons'; import onHasCompletion from './onHasCompletion'; let CodeMirror; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; if (!SERVER_RENDERED) { CodeMirror = require('codemirror'); diff --git a/packages/bruno-app/src/components/SingleLineEditor/index.js b/packages/bruno-app/src/components/SingleLineEditor/index.js index 31d0875fd..16413bdf3 100644 --- a/packages/bruno-app/src/components/SingleLineEditor/index.js +++ b/packages/bruno-app/src/components/SingleLineEditor/index.js @@ -6,7 +6,7 @@ import StyledWrapper from './StyledWrapper'; import { IconEye, IconEyeOff } from '@tabler/icons'; let CodeMirror; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; if (!SERVER_RENDERED) { CodeMirror = require('codemirror'); diff --git a/packages/bruno-app/src/pages/Bruno/index.js b/packages/bruno-app/src/pages/Bruno/index.js index 71e24dcfa..b789e6ddd 100644 --- a/packages/bruno-app/src/pages/Bruno/index.js +++ b/packages/bruno-app/src/pages/Bruno/index.js @@ -10,7 +10,7 @@ import 'codemirror/theme/material.css'; import 'codemirror/theme/monokai.css'; import 'codemirror/addon/scroll/simplescrollbars.css'; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; if (!SERVER_RENDERED) { require('codemirror/mode/javascript/javascript'); require('codemirror/mode/xml/xml'); diff --git a/packages/bruno-app/src/pages/_app.js b/packages/bruno-app/src/pages/_app.js index 331638070..08ebe6b0b 100644 --- a/packages/bruno-app/src/pages/_app.js +++ b/packages/bruno-app/src/pages/_app.js @@ -8,7 +8,6 @@ import ReduxStore from 'providers/ReduxStore'; import ThemeProvider from 'providers/Theme/index'; import ErrorBoundary from './ErrorBoundary'; -import '../styles/app.scss'; import '../styles/globals.css'; import 'codemirror/lib/codemirror.css'; import 'graphiql/graphiql.min.css'; @@ -31,7 +30,7 @@ function SafeHydrate({ children }) { } function NoSsr({ children }) { - const SERVER_RENDERED = typeof navigator === 'undefined'; + const SERVER_RENDERED = typeof window === 'undefined'; if (SERVER_RENDERED) { return null; diff --git a/packages/bruno-app/src/utils/common/codemirror.js b/packages/bruno-app/src/utils/common/codemirror.js index cbb1a2b3a..53cbcf9a0 100644 --- a/packages/bruno-app/src/utils/common/codemirror.js +++ b/packages/bruno-app/src/utils/common/codemirror.js @@ -1,7 +1,7 @@ import get from 'lodash/get'; let CodeMirror; -const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; +const SERVER_RENDERED = typeof window === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true; if (!SERVER_RENDERED) { CodeMirror = require('codemirror');