跨源读取阻塞(corb)使用mime类型text/html阻塞跨源响应< url>

mkshixfv  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(592)

我已经被这个问题困扰了几天,场景是我有两个不同的服务器在运行,并且实现了sso(单点登录),我需要从服务器1获取图像资源(http://127.0.0.1:8888)到服务器2(http://localhost:8082)
在服务器1上

@CrossOrigin("*")
    @GetMapping(value = "/{a}/{b}/content/i/{c}/{d}", produces = {MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_PNG_VALUE, "image/jpg"})
    public ResponseEntity<Resource> showImage(@PathVariable(name="a") UUID fo1, @PathVariable(name="b") UUID fo2,
             @PathVariable(name="c") UUID fo3, @PathVariable(name="imageName") String fo4) {                
                Optional<Domain> image = domainService.findByUuId(fo3);
                    final HttpHeaders headers = new HttpHeaders();
                    headers.setContentType(MediaType.valueOf(image.get().getFileMimeType()));
                    headers.setAccessControlAllowOrigin("*");
                    return ResponseEntity.ok().headers(headers).body(new ByteArrayResource(Files.readAllBytes(Paths.get(image.get().getActImgPath()))));

    }

在服务器2上:

<img src="http://127.0.0.1:8888/a/b/content/i/c/d.jpg">

它在firefox中运行良好,但在google chrome和microsoft edge中运行不正常

Cross-Origin Read Blocking (CORB) blocked cross-origin response http://127.0.0.1:8888/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

如何解决?我的请求和响应头信息如下所示;

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题