Merge pull request 'feat(security): add frontend host configuration property' (!146) from bugfix/backend-cors into main
Reviewed-on: #146
This commit is contained in:
commit
a22bfa4a60
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
package de.szut.casino.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.Customizer;
|
||||
|
@ -17,6 +18,9 @@ import java.util.List;
|
|||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
@Value("${app.frontend-host}")
|
||||
private String frontendHost;
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
|
@ -36,7 +40,7 @@ public class SecurityConfig {
|
|||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
configuration.setAllowedOrigins(List.of("http://localhost:4200"));
|
||||
configuration.setAllowedOrigins(List.of(this.frontendHost));
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token", "Access-Control-Allow-Origin"));
|
||||
configuration.setExposedHeaders(List.of("x-auth-token"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue