node.js - 允许使用 node Express 进行跨域页面访问
问题描述
我正在尝试使用 iframe 在我的开发环境中访问跨域页面。
这是 Express js 在 http://localhost:5000 提供的主机页面。它有一个嵌入式 iframe,它试图访问在 http://localhost:3000 上运行的 React 应用程序。
<!DOCTYPE html>
<html>
<body>
<h1>Host Page</h1>
<iframe
id="child"
src="http://localhost:3000"
scrolling="no"
sandbox="allow-popups allow-scripts allow-same-origin"
style="width: 1px; min-width: 100%; border-width: 0;"
></iframe>
</body>
</html>
但是,当此页面出现时,iframe 显示以下错误:
SecurityError: 阻止了来源为“http://localhost:3000”的框架访问跨域框架。
使这项工作最简单的方法是什么?这只是为了我的本地开发 - 没有任何安全问题!
解决方案
推荐阅读
- ruby-on-rails - 为什么这个使用 will_paginate 的无限滚动不起作用?
- laravel - Laravel 数据透视表生成不起作用(返回一般错误:1005 无法创建表)
- angular - parent.appendChild 不是函数
- javascript - 使用 JavaScript 创建 16x16 网格
- linux-kernel - 我应该手动编辑`.config`文件以禁用Linux内核中的`AUDITSYSCALL`吗?
- arrays - VBA,此“x = Array()”的替代代码
- excel - 使用 VBA 循环遍历特定列
- ios - 你如何实现,firebase完成这个源
- php - 使用资源显示数据后分页不显示
- c++ - 这个 if 语句有什么捷径吗?