前后端跨域出现Cross-Origin Read Blocking (CORB) blocked cross-origin报错

kingofdancer kingofdancer 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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请求:
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();
}
}
...全文
评论 8
收藏 已收藏
分享
返回顶部
kingofdancer
Java 51,407 成员 86,127 内容