No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.

简介: No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.

【解决跨域问题】 Access to XMLHttpRequest at ‘http://localhost:3000/’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

一、报错的原因

原因:浏览器同源策略限制了此类请求。

二、什么是同源策略?

同源策略它是由 Netscape 提出的一个安全策略,它是浏览器最核心也是最基本的安全功能,如果缺少同源策略,则浏览器的正常功能可能都会受到影响,现在所有支持JavaScript的浏览器都会使用这个策略。

所谓同源指的是:协议、域名、端口号都相同,只要有一个不相同,那么都是非同源。

浏览器在执行脚本的时候,都会检查这个脚本属于哪个页面,即检查是否同源,只有同源的脚本才会被执行;而非同源的脚本在请求数据的时候,浏览器会报一个异常,提示拒绝访问。

二、解决办法


相关文章
|
9月前
|
Java API 语音技术
MRCP(Media Resource Control Protocol)
MRCP(Media Resource Control Protocol)是一种音视频资源控制协议,用于控制语音识别、语音合成和语音交互等场景中的音视频资源。阿里云语音交互服务(ASR、TTS、Chatbot)支持MRCP协议,您可以使用MRCP协议来控制音视频资源,并实现语音交互的功能。
1218 1
|
4月前
|
JavaScript 前端开发
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
52 0
|
API
【已解决】No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
274 0
【已解决】No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
|
9月前
|
前端开发 JavaScript
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
ajax请求的重定向处理--Request header field x-requested-with is not allowed by Access-Control-Allow-Header
319 0
|
JavaScript Java 应用服务中间件
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
1585 0
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
|
11月前
|
Web App开发 存储 安全
新版本Chrome同源策略、跨域问题处理No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
新版本Chrome同源策略、跨域问题处理No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
501 0
|
应用服务中间件 API nginx
解决跨域问题 Response to preflight request doesn't pass access control check
解决跨域问题 Response to preflight request doesn't pass access control check
9045 0
|
存储 NoSQL Redis
docker: denied: requested access to the resource is deniedunauthorized: authentication required
docker: denied: requested access to the resource is deniedunauthorized: authentication required
478 0
docker: denied: requested access to the resource is deniedunauthorized: authentication required
|
前端开发 数据可视化 Java
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
1093 0
|
JavaScript 应用服务中间件 nginx
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight respo

热门文章

最新文章