我尝试使用 js 代码来获取远程(spring boot)js 代码,它显示Cross-Origin Read Blocking (CORB) blocked cross-origin response http://45.82.79.208/ with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details我的js代码:var script = document.createElement("script");script.type = "text/javascript";script.src = "http://45.82.79.208/";document.head.appendChild(script);我的 Spring Boot 代码,允许 cros:@Configurationpublic class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") // allow cros path .allowedOrigins("*") // allow cros origin .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")// allow method .maxAge(168000) // .allowedHeaders("*") .allowCredentials(true); }}我的代码有问题吗?如何解决此问题以允许 CORS?
2 回答

手掌心
TA贡献1942条经验 获得超3个赞
根据该页面,响应类型不正确。可以尝试设置js的响应头(content-type)
它将阻止从 a 或 标记请求的跨源文本/html 响应,并将其替换为空响应
添加回答
举报
0/150
提交
取消