Script error.解决方法
1. 添加 crossorigin="anonymous" 到script标签
<script src="https://xxx.com/xxx.js" crossorigin="anonymous"></script> |
crossorigin可以取枚举值anonymous或则use-credentials。
The “anonymous” keyword means that there will be no exchange of user credentials via cookies, client-side SSL certificates or HTTP authentication
anonymous即不发送Cookie和HTTP认证信息,对于静态资源,我们使用anonymous就已经足够。 关于crossorigin详情可以参考: CORS settings attributes
2. 添加支持跨域访问的设置
Access-Control-Allow-Origin: * |
Access-Control-Allow-Origin是HTML5中定义的一种解决资源跨域的策略。他是通过服务器端返回带有Access-Control-Allow-Origin标识的Response header,用来解决资源的跨域权限问题。
CDN服务商比如七牛默认已经配置好了Access-Control-Allow-Origin,使用curl命令获取头部:
curl --head https://js.fundebug.cn/fundebug.0.0.4.min.js | grep "Access-Control-Allow-Origin" |
结果如下:

如果您有单独的子域名(子域名也会被认定为不同源)用来分发静态资源,那么需要在服务端做一点配置。针对不同语言和框架的配置方法我们不一一列出,Nodejs的Express框架下是这样配置的:
app.use(function(req, res, next) |
其它设置Access-Control-Allow-Origin请参考
- PHP: ajax 设置Access-Control-Allow-Origin实现跨域访问
- Java: Java 无法跨域问题(No ‘Access-Control-Allow-Origin’..)
- Nginx: nginx Access-Control-Allow-Origin css跨域
https://blog.fundebug.com/2017/04/05/understand-script-error/
https://blog.fundebug.com/2017/04/06/test-script-error/
https://blog.fundebug.com/2017/04/07/solve-script-error/
Script error.解决方法的更多相关文章
- eclipse maven update error 解决方法
eclipse maven update error 解决方法 本来真不想写这篇博文的,但是eclipse和maven真的是太操蛋了,动不动就出了一些乱七八糟的问题,记录一下.希望公司能早 ...
- VMware unrecoverable error解决方法
把开发环境部署在虚拟机里面,重装系统后不须要再反复部署开发环境. 可是有时候异常退出虚拟机会导致错误.之前出现打开虚拟机之后,系统分辨率错误,就是点击的位置和显示的位置不一样. 于是又一次关了虚拟机, ...
- make menuconfig error 解决方法记录
新建的一个虚拟机,发现make menuconfig 后会出错,查了一下是缺少一些库. 这个错误已经错了两次了,我不希望第三次出现了还想不起来,所以特此记录. # 错误信息: make[2]: *** ...
- Microsoft Visual C++ Runtime error解决方法
1: 当出现下图时提示Microsoft Visual C++ Runtime error 2:此时不要关闭该对话框,然后打开任务管理器(Ctrl+Shift+Esc)如下图: 找到Microsoft ...
- 常见sql的error解决方法
1.sqlserver 2008 login failed: error 18456 这是很可能是因为你没有选择sql and windows登录的模式导致sql server的用户登录失败 解决方法 ...
- Eclipse build error 解决方法The library '*.jar' contains native libraries that will not run on the dev
[2013-08-29 16:56:58 - jarsotest] The library 'wnp.jar' contains native libraries that will not run ...
- libtool: Version mismatch error. 解决方法
在编译一个软件的时候,在 ./configure 和 make 之后可能会出现如下错误: libtool: Version mismatch error. This is libtool 2.4. ...
- jquery中ajax请求后台数据成功后既不执行success也不执行error解决方法
jquery中ajax请求后台数据成功后既不执行success也不执行error,此外系统报错:Uncaught SyntaxError: Unexpected identifier at Objec ...
- keil5下载程序时出现“internal command error”解决方法
今天下载的时候,插入下载器,查看Debug可用看到“internal command error”,一直找不到原因,后来查看上一个工程才发现,上一个程序禁用了Seral Wire 引脚,导致的. 解决 ...
随机推荐
- SoapUI 学习总结-02 断言
一 断言 测试指定的restful api是否正常,判断它的响应值是否符合预期标准,需要用到断言知识.在soapUI里断言使用的Groovy语言.在项目中测试起来非常简单,测试过程如下. 1,准备测试 ...
- Linux 修改本地时间 (centos为例)
1. tzselect [root@xxxx etc]# tzselect --- 选择时区命令 Please identify a location so that time zone rules ...
- OracleSql语句学习(四)
SELECT e.ename,m.ename,d.locFROM emp_weiyiji e JOIN emp_weiyiji m ON e.mgr=m.empnoJOIN dept_weiyiji ...
- Data Governance
https://erwin.com/blog/data-preparation-mapping/
- 关于vue打包是因代码校验报错
单个文件中: 1./* eslint - disable */ 2./* eslint-disable no-new */ 当然也支持全局: 3.bulid > webpack.base.con ...
- Python——序列化模块
#json 模式 1.dumps.loads 方法 针对内存 dic = {'k1':'v1'} #转换成json import json str_d = json.dumps(dic) #序列化 ...
- socketserver和socket的补充(验证客户端合法性)
一.socket的补充 1.参数 socket.socket(family=AF_INET,type=SOCK_STREAM,proto=0,fileno=None) 参数说明: family 地址系 ...
- mpvue——动态渲染echarts图表
前言 使用mpvue-echarts来写图表,那个F2再提醒自己下要踩坑不能忘记.遇到了一个问题就是数据不能动态的去渲染,这个其实官方给了我们对应的方法 懒加载 代码 修改了调用initChart() ...
- Android Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency
错误内容: Error:Execution failed for task ':app:preDebugAndroidTestBuild'.> Conflict with dependency ...
- python发送smtp 邮件 图片
#-*- coding: utf-8 -*- # python2 import os import time import random import smtplib from time import ...