使用chrome谷歌瀏覽器先後端接口調試的時候遇到了這個問題:
network前端
Provisional headers are shown
consoleweb
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
錯誤緣由實際上是跨域的問題,後端須要設置容許跨域就能夠了。chrome
個人項目是spring boot項目,配置跨域以下:json
@Configuration public 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); } }