1
1
package de .filefighter .rest .configuration ;
2
2
3
- import org .springframework .context .annotation .Bean ;
4
- import org .springframework .context .annotation .Configuration ;
5
- import org .springframework .web .cors .CorsConfiguration ;
6
- import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
7
- import org .springframework .web .filter .CorsFilter ;
8
-
9
- import java .util .ArrayList ;
10
- import java .util .Arrays ;
11
-
12
- @ Configuration
13
3
public class RestConfiguration {
14
4
15
5
//Custom static constants
@@ -21,17 +11,7 @@ public class RestConfiguration {
21
11
public static final String USER_BASE_URI = "/users/" ;
22
12
public static final String DEFAULT_ERROR_PATH = "/error" ;
23
13
24
- @ Bean
25
- public CorsFilter corsFilter (){
26
- final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
27
- final CorsConfiguration config = new CorsConfiguration ();
28
- // Don't do this in production, use a proper list of allowed origins
29
- ArrayList <String > allowedOrigins = new ArrayList <>();
30
- allowedOrigins .add ("http://localhost:3000" );
31
- config .setAllowedOrigins (allowedOrigins );
32
- config .setAllowedHeaders (Arrays .asList ("Origin" , "Content-Type" , "Accept" ));
33
- config .setAllowedMethods (Arrays .asList ("GET" , "POST" , "PUT" , "OPTIONS" , "DELETE" , "PATCH" ));
34
- source .registerCorsConfiguration ("/**" , config );
35
- return new CorsFilter (source );
14
+ private RestConfiguration (){
15
+ // Cannot be inst
36
16
}
37
- }
17
+ }
0 commit comments