我之前报的错误:
When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
网上有很多解决手法,都差不多,只需加这段代码:
List<String> allowedOriginPatterns = new ArrayList<>(); allowedOriginPatterns.add("*"); corsConfiguration.setAllowedOriginPatterns(allowedOriginPatterns);
没有用,我仔细阅读报的错误,其实已经告诉我了,是要这样改:
corsConfiguration.setAllowCredentials ( true );
改:
corsConfiguration.setAllowCredentials ( false );
完整的代理是这样的:
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfigurat