Skip to content

Commit

Permalink
temp: disable cors checking
Browse files Browse the repository at this point in the history
  • Loading branch information
peageon committed May 21, 2024
1 parent b204980 commit 143ae29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
Expand All @@ -39,8 +40,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
httpBasic.disable())
.csrf((csrf) ->
csrf.disable())
.cors((cors) ->
cors.disable())
.cors(Customizer.withDefaults())
.sessionManagement((sessionManagement) ->
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(((authorizeRequest) ->
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/runningmate/backend/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.runningmate.backend.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*") // Allow all origins
.allowedMethods("*") // Allow all methods (GET, POST, etc.)
.allowedHeaders("*") // Allow all headers
.allowCredentials(true);
}
}

0 comments on commit 143ae29

Please sign in to comment.