

跨域问题解决Access to image at 'file:///png' from origin 'null' has been blocked...
source link: https://www.cnblogs.com/tuyile006/p/15619697.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

跨域问题解决Access to image at 'file:///png' from origin 'null' has been blocked by CORS policy
在谷歌浏览器中出现
Access to image at 'file:///C:/Users/DK/Desktop/threejs%E5%AD%A6%E5%A0%82/material/g8.png' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
这是浏览器安全不允许跨域访问,即使是访问本地文件也不行,必须是以http,https网络请求方式访问。
网上解决办法是:crossorigin="anonymous"
以及浏览器快捷方式加参数:chrome.exe --disable-web-security (后患无穷)
正确的解决办法是:建立本地服务器,现在介绍一分钟建立本地服务器的办法
方法一:Servez
简介:https://greggman.github.io/servez/
该服务器支持mac,linux,windows。
window版直接下载exe文件即可,有界面,选择要建站的文件夹,点Start 就可以了。相当简单。
方法二:Node.js http-server
下载安装http-server
npm install --global http-server C:\Users\mybj\AppData\Roaming\npm\hs -> C:\Users\mybj\AppData\Roaming\npm\node_modules\http-server\bin\http-server C:\Users\mybj\AppData\Roaming\npm\http-server -> C:\Users\mybj\AppData\Roaming\npm\node_modules\http-server\bin\http-server + [email protected] added 30 packages from 40 contributors in 6.6s
启动http-server
http-server [path] [options]
[path]的默认值:先找 ./public
,否则使用 ./
。
复制$ http-server Starting up http-server, serving ./ Available on: http://192.168.17.140:8081 http://192.168.44.1:8081 http://192.168.208.1:8081 http://192.168.137.1:8081 http://127.0.0.1:8081 Hit CTRL-C to stop the server
效果如下:
Recommend
-
50
I had a situtation last week with requests to server from Vue using Axios where data field has been empty. Server had CORS (
-
19
zuul+security跨域Cors问题解决 简介 场景 在服务后台都会出现跨域cors问题,不过一般spring解决起来比较方便,在框架+框架的基础上,问题就显得特别明显了,各种冲突,不了解源码的运行原理,解决起来...
-
40
源码 package main import ( "github.com/gin-gonic/gin" "strings" "fmt" "net/http" ) func main() { r := gin.Default() r.Use(Cors()) //开启中间件 允许使用跨域请求 r.run() }...
-
48
Nuxt 是 Vue 项目服务器端渲染(SSR)解决方案。而在使用时,就会遇到前后端分离情况下的域名或端口不一致导致的跨域问题。本文将介绍如何通过设置代理解决 Nuxt 与
-
49
<h1> Go | Gin 解决跨域问题跨域配置 </h1> 前言 在前后端分离的项目中,经常会遇到跨域问题,遇到问题该如何解决呢?! 一、关于跨域解决方案 关于跨域的解决方法,大部分可以分为...
-
9
Django 通过设置 CORS 解决跨域问题 一、Ajax 跨域请求Ajax 请求一个目标地址为非本域(协议、主机、端口任意一个不同)的 web 资源。 前端http://192.168.10.50:8080 后端
-
41
后端域名为A.abc.com,前端域名为B.abc.com。浏览器在访问时,会出现跨域访问。浏览器对于javascript的同源策略的限制。 HTTP请求时,请求本身会返回200,但是返回结果不会走success,并且会在浏览器console中提示: 已拦截跨源请求:同源策略禁...
-
8
前后端分离项目跨域问题是不可避免的。通常情况下前端由React、Vue等框架编写,通过ajax请求服务端API,传输数据用json格式。 那么为什么...
-
7
by zhangxinxu from http://www.zhangxinxu.com/wordpress/?p=7378 本文可全文转载,但需要保留原作者和出处。 一、首先,图片服务器需要...
-
10
Cookie1993 迎来了 img 标签,这是 web 第一次迎来了资源加载<img src="foo.jpg" /> <img src="http://somewhere.com/foo.jpg" />Set-Cookie: foo=bar
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK