惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 新房客

iOS中判断Apple Pencil力度与手触摸 Electron,VUEJS3,Vite,TypesSript 开发环境配置 安卓2022.3.11环境配置 网上设置的跨域基本都失效了,新的设置方式 从模型坐标到屏幕坐标 群晖中使用Docker安装备份升级Gitlab vscode Typescript自动修复引入类时,引号设置 基于nodejs的阿里云DDNS服务,支持多网卡绑定 WebGL与Canvas的显存与内存使用分析 基于nodejs的游戏服务器 typescript 中 d.ts module 与 namespace 区别 使用vs code与microsoft edge调试webpack项目 解决Jenkins无法编译Egret5.0项目的问题 筛选git最后一次文件列表 推荐一个不错的plist拆解工具,untp - 新房客 - 博客园 vs code(egret wing) php配置与调试 关于 typings install 的使用 angular 引入 component 报错 angular2 环境配置
html5 js跨域
新房客 · 2016-05-10 · via 博客园 - 新房客

介绍

当我们使用XMLHttpRequest发送请求时,浏览器发现该请求不符合同源策略,会给该请求加一个请求头:Origin,后台进行一系列处理,如果确定接受请求则在返回结果中加入一个响应头:Access-Control-Allow-Origin;浏览器判断该相应头中是否包含Origin的值,如果有则浏览器会处理响应,我们就可以拿到响应数据,如果不包含浏览器直接驳回,这时我们无法拿到响应数据。

一般设置分为两种,一种是动态请求,一种是服务器设置。

动态请求

<?php
header("Access-Control-Allow-Origin:*");
?>

解决方法就是 在资源的头中 加入 Access-Control-Allow-Origin 指定你授权的域. 我这里无所谓,就指定星号 * , 任何域都可以访问我的资源.一般在正式的生产环境中应该写入具体的地址。

服务器设置

location / {
  add_header Access-Control-Allow-Origin *;
}

这里是以nginx的conf文件中添加的内容。

目前的兼容性