Changes between Version 4 and Version 5 of Other topics


Ignore:
Timestamp:
04/29/26 23:48:18 (2 days ago)
Author:
231035
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Other topics

    v4 v5  
    146146    }
    147147}}}
     148=== CORS
     149* The application uses a CORS configuration to control which frontend clients are allowed to communicate with the backend API. In development, requests are allowed only from local frontend origins such as http://localhost:*(this will be changed to the correct URL of the hosted site). The configuration defines the permitted HTTP methods, including GET, POST, PUT, PATCH, DELETE, and OPTIONS.
     150{{{
     151@Bean
     152    public CorsConfigurationSource corsConfigurationSource() {
     153        CorsConfiguration configuration = new CorsConfiguration();
     154        configuration.setAllowedOriginPatterns(List.of("http://localhost:*"));
     155        configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT","PATCH", "DELETE", "OPTIONS"));
     156        configuration.setAllowedHeaders(Arrays.asList("*"));
     157        configuration.setAllowCredentials(true);
     158
     159        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
     160        source.registerCorsConfiguration("/**", configuration);
     161        return source;
     162    }
     163}}}
    148164
    149165== Other developments