首页 > 解决方案 > 赛普拉斯无法加载 localhost 之外的任何内容。无法使用 CDN 或 Google 字体

问题描述

我遇到了赛普拉斯的问题,赛普拉斯打开的 Chrome 窗口无法从 jquery CDN 和 Google 字体文件访问链接的静态文件,如 jQuery。

index.html我得到这些行:

<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link href="//fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">

通过打开https://localhost:8000/index.html(我必须在 HTTPS 模式下运行网站)在普通 Chrome 窗口中打开我的网站时,这些文件会加载状态代码 200,但是当赛普拉斯尝试在赛普拉斯窗口中加载它们时,我会得到(failed).

即使我尝试在 Cypress 窗口中打开一个新选项卡并输入除 localhost 之外的任何 URL,它也不会加载。

这是我的cypress.json文件,我在其中禁用了chromeWebSecurity

{
  "integrationFolder": "cypress/integration",
  "supportFile": "cypress/support/index.ts",
  "videosFolder": "cypress/videos",
  "screenshotsFolder": "cypress/screenshots",
  "pluginsFile": "cypress/plugins/index.ts",
  "fixturesFolder": "cypress/fixtures",
  "baseUrl": "https://localhost:8000",
  "chromeWebSecurity": false,
  "defaultCommandTimeout": 15000,
  "pageLoadTimeout": 150000,
  "viewportWidth": 1280,
  "viewportHeight": 720
}

有人处理过这个问题并能够克服它吗?

标签: localhostcypressstatic-content

解决方案


推荐阅读