CORS problem when trying to load on the map a custom KML

22 views
Skip to first unread message

Giuseppe Riccardi

unread,
Dec 8, 2025, 5:51:32 PM (6 days ago) Dec 8
to GeoAdminCh API
Hello all,

from few days we noticed that we are unable to load in the map our custom KML.
We are facing always a cors error that we aren't able to explain.
This is our current Spring boot configuration:
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.securityMatcher("/**")
.cors((cors) -> cors.configurationSource(apiConfigurationSource()))
.csrf(CsrfConfigurer::disable);
return http.build();
}

CorsConfigurationSource apiConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(List.of("*"));
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "HEAD", "OPTIONS"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/map/**", configuration);
return source;
}

And this is he configuration on the single endpoint that the map is trying to load:
@CrossOrigin(origins = "https://map.geo.admin.ch")
@GetMapping("/map/kml")
public void createKml(@RequestParam("id") String id, @RequestParam("distance") int distance, @RequestParam("lang") String lang, @RequestParam(name = "withDescription", required = false, defaultValue = "false") Boolean withDescription, @RequestParam(name = "showNames", required = false, defaultValue = "false") Boolean showNames, HttpServletRequest request, HttpServletResponse response) {
/** BODY **/
}


Do you have any idea why is not possible to load it? Has something changed on your side? 

Best regards,
Giuseppe Riccardi




GeoAdminCh API

unread,
Dec 10, 2025, 3:25:07 AM (5 days ago) Dec 10
to GeoAdminCh API
Hi Giuseppe

Could you please provide us more details, such as a link to the KML you try to load?
Did you try importing it into map.geo.admin.ch directly, additionally to trying to import it into your own app?
Does that work?

Thanks a lot
Juergen

Reply all
Reply to author
Forward
0 new messages