新西兰天维网社区

标题: 请教下,关闭react developer tool的代码放在哪里比较安全啊? [打印本页]

作者: DDD888    时间: 2019-6-5 15:14:13     标题: 请教下,关闭react developer tool的代码放在哪里比较安全啊?

<script>
            // https://remarkablemark.org/blog/ ... ble-react-devtools/
            // before React is loaded
            if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
                __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
            }

            // https://github.com/mobxjs/mobx-devtools/issues/51
            if (typeof window.__MOBX_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
                __MOBX_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
            }
</script>

我现在放在root 的index.html的head里,但太明显啦,一共就几行代码,被黑客一看就知道啦,放在project哪里比较隐蔽啊?

谢谢


作者: 饺子饺子    时间: 2019-6-5 15:21:30

本帖最后由 饺子饺子 于 2019-6-5 15:29 编辑

webpack时, 放到你的APP code里就可以了
作者: DDD888    时间: 2019-6-6 12:35:20

饺子饺子 发表于 2019-6-5 15:21
webpack时, 放到你的APP code里就可以了

我最后的解决方案是

生成firstImport.js 放在src\index.js同目录下
if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
    window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
}

// https://github.com/mobxjs/mobx-devtools/issues/51
if (typeof window.__MOBX_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
    window.__MOBX_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
}
在index.js第一个import,如果我要调试的话就comment import line
import './firstImport';
作者: 注册会计师    时间: 2019-9-7 18:07:33

DDD888 发表于 2019-6-6 12:35
我最后的解决方案是

生成firstImport.js 放在src\index.js同目录下

奥克兰有react的兴趣group小组吗?
作者: DDD888    时间: 2019-9-7 18:17:15

注册会计师 发表于 2019-9-7 18:07
奥克兰有react的兴趣group小组吗?

就在这啦
作者: 注册会计师    时间: 2019-10-29 12:36:12

DDD888 发表于 2019-6-6 13:35
我最后的解决方案是

生成firstImport.js 放在src\index.js同目录下

as react is a SPA, so all sensitive code should not be in the client-app at all.

always use axios / fetch to back to the api server to perform any sensitive functions.
作者: DDD888    时间: 2019-10-29 13:24:41

注册会计师 发表于 2019-10-29 13:36
as react is a SPA, so all sensitive code should not be in the client-app at all.

always use axio ...

Please read my question and post your valuable comments. Otherwise no one will care your comments.




欢迎光临 新西兰天维网社区 (http://bbs.skykiwi.com/) Powered by Discuz! X2