使用chrome谷歌浏览器前后端接口调试的时候遇到了这个问题:
network

Provisional headers are shown

console

Cross-Origin Read Blocking (CORB) blocked cross-origin response http://xxx:180/test?id=1035 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

如果使用其它浏览器或者postman等测试工具测试的话又可以调用。

错误原因其实是跨域的问题,后端需要设置允许跨域就可以了。

我的项目是spring boot项目,配置跨域如下:

@Configurationpublic class CorsConfig {    private CorsConfiguration buildConfig() {        org.springframework.web.cors.CorsConfiguration corsConfiguration = new CorsConfiguration();        corsConfiguration.addAllowedOrigin("http://127.0.0.1:800"); // 1这就是前端调用放的origin,可以在network中查看        corsConfiguration.addAllowedHeader("*"); // 2允许任何头        corsConfiguration.addAllowedMethod("*"); // 3允许任何方法(post、get等)        return corsConfiguration;    }    @Bean    public CorsFilter corsFilter() {        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();        source.registerCorsConfiguration("/**", buildConfig()); // 4        return new CorsFilter(source);    }}