是的,CorsConfiguration.addAllowedOrigin 可以添加多个允许的来源。例如:

CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin('http://localhost:8080');
corsConfiguration.addAllowedOrigin('http://example.com');

这样配置后,允许的来源就是 'http://localhost:8080' 和 'http://example.com'。

Spring Boot CORS 配置:允许多个来源

原文地址: https://www.cveoy.top/t/topic/mx4G 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录