前后端跨域出现Cross-Origin Read Blocking (CORB) blocked cross-origin报错
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://www.xxx.net.cn:24058/hnlz-archivesz/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
一直报这个错 我都不知道是我前端ajax问题还是后端接口问题 代码我全贴 希望大佬帮我解决 蟹蟹
前端ajax请求:
后台接口代码
一直报这个错 我都不知道是我前端ajax问题还是后端接口问题 代码我全贴 希望大佬帮我解决 蟹蟹
前端ajax请求:
layui.$.ajax({
beforeSend: function (request) {
request.setRequestHeader("Accept",'application/json');
//request.setRequestHeader("Access-Control-Allow-Methods:POST,GET");
request.setRequestHeader('Content-Type', 'application/json');
},
url: 'http://www.xxx.net.cn:30334/ArchiveHNBackend/person/platform',//这里是地址
type: "get",
dataType: "jsonp",//跨域
crossDomain: true,
//contentType: "application/x-www-form-urlencoded; charset=utf-8",
//jsonp: "callback",
data: { "name": data.PersonName },
success: function (data) {
console.log(data);
}
});后台接口代码
@RequestMapping("/platform")
public void platformList(@RequestParam String name,HttpServletRequest request,HttpServletResponse response){
/*PageHelper.startPage(1, 100);
List<Person> list = personService.platformList(name);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);*/
String token ="";
Users users = null;
users = usersService.findByUserName(UNAME);
long time = System.currentTimeMillis();
String subject = users.getUsername() + ","
+ users.getRealname() + ","
+ users.getRoleid() + ","
+ users.getId() + ","
+ users.getDeptid();
token = Jwts.builder()
.setSubject(subject)
// 设置过期时间 1 * 24 * 60 * 60秒情况修改)
.setExpiration(new Date(time + JwtConfig.Time))
//采用什么算法是可以自己选择的,不一定非要采用HS512
.signWith(SignatureAlgorithm.HS512, JwtConfig.SIGNING_KEY)
.compact();//压缩成XXXX.XXX格式
UserDto u = new UserDto();
u.setToken(token);
try {
redis.setStr(users.getUsername(), token);
} catch (Exception e) {
e.printStackTrace();
}
//log.info("用户" + users.getUsername() + "成功登陆");
try {
response.sendRedirect(URL + "token=" + token + "&code=" + 200 + "&homepage=Dashboard" + "&condition="+name);
response.setHeader("Access-Control-Allow-Origin", "http://localhost:6223");
response.setHeader("Access-Control-Allow-Credentials", "true");
//解决跨域
//getJsonpData(request,response);
System.out.println(response);
} catch (IOException e) {
e.printStackTrace();
}
}
...全文
相关推荐
浏览器跨域插件Moesif Origin & CORS Changer 0.4.7
浏览器跨域插件Moesif Origin & CORS Changer 0.4.7。解决跨域Cross-Origin Read Blocking (CORB) blocked cross-origin response。亲测有效
js 跨域解决方案
解决js的跨域问题
详解JavaScript跨域总结与解决办法
本篇文章主要介绍了JavaScript跨域,详细的总结了什么是跨域,并介绍了几种解决办法,感兴趣的小伙伴们可以参考一下。
java服务器端解决跨域问题共6页.pdf.zip
java服务器端解决跨域问题共6页.pdf.zip
使用jsonp完美解决跨域问题
在项目中遇到错误提示“No 'Access-Control-Allow-Origin' header is present on the requested resource.”查了下度娘,这个问题和安全机制有关,默认不允许跨域调用,这里记录一下解决方案,防止以后再犯相同的错误。


