小编Sea*_*ean的帖子

“访问被拒绝 | <url> 使用 Cloudflare 限制访问”GET 请求 Postman

我目前正在使用 Postman 测试 GET 请求。我只是想看看我能得到什么样的信息。大多数情况下,只需插入网站的网址即可。然而,有一个特定的网站给我带来了麻烦。当我尝试发起 GET 请求时,出现以下错误:

<title>Access denied | <url> used Cloudflare to restrict access</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css"
    media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->
Run Code Online (Sandbox Code Playgroud)

该网站直接在 Chrome 中启动时运行良好。但是,每次我尝试在 Postman 中发送 GET 时,都会收到 403 响应。我已经尝试了一些解决方案:

  • 复制并粘贴 Chrome 检查工具中显示的用户代理 (Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML,如 Gecko) Chrome/80.0.3987.149 Safari/537.36)。
  • 设置状态为“INTERCEPTOR CONNECTED”的 Postman …

http cloudflare postman

12
推荐指数
1
解决办法
2万
查看次数

Jest 中的嵌套模拟函数

我目前正在尝试测试模拟我的一些笑话功能。我遇到的问题之一是尝试模拟在另一个函数内部调用的函数。这是我正在尝试做的事情的高级示例:

//Apple.js
function Apple(){
   return Orange(1, 2);
}

function Orange(arg1, arg2){
   return (arg1 + arg2);
}
Run Code Online (Sandbox Code Playgroud)

我想测试 Apple 功能而不实际调用 Orange。在 .spec.js 文件中模拟我的橙色函数以使类似的事情发生的代码是什么?我当时在想类似以下的事情,但我对此表示怀疑:

//Apple.spec.js
import Apple from "Apple.js";
it("Should run Apple", () => {
   global.Orange = jest.fn().mockImplementation(() => {return 3});
   expect(Apple()).toEqual(3);
});
Run Code Online (Sandbox Code Playgroud)

这是一个非常简单的例子,但了解这一点肯定会帮助我理解项目的下一步。我希望尽快收到社区的来信!

javascript testing unit-testing mocking jestjs

5
推荐指数
1
解决办法
6283
查看次数

更改纸张颜色 Material-UI

我正在使用 material-ui 库开发一个 React 项目。我目前正在尝试添加一个对我来说很好用的抽屉。但是,我正在尝试更改此抽屉的背景颜色。我听说这样做的方法是改变抽屉纸的颜色。我尝试将以下标签添加到我的 CSS 对象中:

const styles = theme => ({
    background:"BLUE"
Run Code Online (Sandbox Code Playgroud)

然后我使用 classNames 库在我的渲染函数中引用这个对象:

  render(){
        const { classes } = this.props;
        return(
    <div className={styles.root}>
    <CssBaseline />
    <Drawer 
    variant="permanent" 
    className={classNames(classes.drawer, {
        [classes.drawerOpen]: this.state.open,
        [classes.drawerClose]: !this.state.open
    })}
    classes = {{
        paper: classNames({
            background:classes.background,
            [classes.drawerOpen]: this.state.open,
            [classes.drawerClose]: !this.state.open
        })
    }}
Run Code Online (Sandbox Code Playgroud)

但是,当我在 localhost 上运行它时,纸张仍然是纯白色的。我是否遗漏了有关 classNames 库的某些信息,或者是纸标签的特例?提前致谢,如果我应该提供比这更多的信息,请告诉我。

javascript css class-names reactjs material-ui

5
推荐指数
1
解决办法
2万
查看次数

React / React-DOM 包依赖冲突

每次尝试运行npm update时,我都会遇到此错误消息:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-website@0.1.0
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   react@"^16.8.0" from the root project
npm ERR!   peer react@"^16.8.0" from @material-ui/core@4.11.0
npm ERR!   node_modules/@material-ui/core
npm ERR!     @material-ui/core@"^4.11.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR!   react-dom@"^17.0.1" from the root project
Run Code Online (Sandbox Code Playgroud)

当我尝试运行npm …

npm reactjs package.json npm-install

5
推荐指数
1
解决办法
5564
查看次数