Access to from origin ‘null‘ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ heade

编程知识 更新时间:2023-04-06 11:22:18
Access to XMLHttpRequest at 'http://localhost:8080/postgres/mvt/source/834/428/10' from origin 
'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

查看其它成功的请求,发现需要给response header加上这个

response.addHeader("access-control-allow-origin", "*");
@Log
@RestController
@RequestMapping("my")
public class MyController {

    private Connection connection;

    @RequestMapping(value = "source/{x}/{y}/{z}",produces = MediaType.IMAGE_PNG_VALUE)
    public byte[] st_AsMvt(@PathVariable("x") Integer x, @PathVariable("y") Integer y, @PathVariable("z") Integer z,HttpServletResponse response) throws Exception {
        /*...*/
        response.addHeader("access-control-allow-origin", "*");
        return bytes;
    }
}

更多推荐

Access to from origin ‘null‘ has been blocked by CORS policy: No ‘Access-Control

本文发布于:2023-04-06 11:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/cc4ae60e1f534b724a7351d7829deeef.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:null   blocked   Access   origin   CORS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 49289文章数
  • 14阅读数
  • 0评论数