fix: prevent dev tools from accessing state in prod (#38669)
* Fixed Redux dev tool plugin in production problem * Update client/src/redux/createStore.js Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * Update client/src/redux/createStore.js Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * Update client/src/redux/createStore.js Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * Update client/src/redux/createStore.js Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Fixed ESLint error * Second try to fix linting issue * Third try to fix lint issues * Update client/src/redux/createStore.js Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update client/src/redux/createStore.js Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: use env.json for ENVIRONMENT Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -169,9 +169,6 @@ exports.onCreateWebpackConfig = ({ stage, plugins, actions }) => {
|
||||
process.env.HOME_PATH || 'http://localhost:3000'
|
||||
),
|
||||
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || ''),
|
||||
ENVIRONMENT: JSON.stringify(
|
||||
process.env.FREECODECAMP_NODE_ENV || 'development'
|
||||
),
|
||||
PAYPAL_SUPPORTERS: JSON.stringify(process.env.PAYPAL_SUPPORTERS || 404)
|
||||
})
|
||||
];
|
||||
|
@ -9,6 +9,8 @@ import rootReducer from './rootReducer';
|
||||
import rootSaga from './rootSaga';
|
||||
import { isBrowser } from '../../utils';
|
||||
|
||||
import { environment } from '../../../config/env.json';
|
||||
|
||||
const clientSide = isBrowser();
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware({
|
||||
@ -29,10 +31,18 @@ const composeEnhancers = composeWithDevTools({
|
||||
});
|
||||
|
||||
export const createStore = () => {
|
||||
const store = reduxCreateStore(
|
||||
rootReducer,
|
||||
composeEnhancers(applyMiddleware(sagaMiddleware, epicMiddleware))
|
||||
);
|
||||
let store;
|
||||
if (environment === 'production') {
|
||||
store = reduxCreateStore(
|
||||
rootReducer,
|
||||
applyMiddleware(sagaMiddleware, epicMiddleware)
|
||||
);
|
||||
} else {
|
||||
store = reduxCreateStore(
|
||||
rootReducer,
|
||||
composeEnhancers(applyMiddleware(sagaMiddleware, epicMiddleware))
|
||||
);
|
||||
}
|
||||
sagaMiddleware.run(rootSaga);
|
||||
epicMiddleware.run(rootEpic);
|
||||
if (module.hot) {
|
||||
|
@ -37,6 +37,7 @@ const locations = {
|
||||
module.exports = Object.assign(locations, {
|
||||
locale,
|
||||
deploymentEnv,
|
||||
environment: process.env.FREECODECAMP_NODE_ENV || 'development',
|
||||
stripePublicKey:
|
||||
!stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard'
|
||||
? null
|
||||
|
Reference in New Issue
Block a user