Skip to content

Commit

Permalink
add: CrossOrigin Annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
limjustin committed Jun 2, 2024
1 parent e18156d commit 0f7e689
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import dev.goormthon.ppoori.domain.comment.dto.CommentRequest;
import dev.goormthon.ppoori.global.common.BaseResponseDto;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import static dev.goormthon.ppoori.global.status.SuccessStatus.COMMENT_SAVE_SUCCESS;

@CrossOrigin(origins = "*", allowedHeaders = "*")
@AllArgsConstructor
@RestController
public class CommentController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import static dev.goormthon.ppoori.global.status.SuccessStatus.*;

@CrossOrigin(origins = "*", allowedHeaders = "*")
@AllArgsConstructor
@RestController
public class PolicyController {
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/dev/goormthon/ppoori/global/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

@Configuration
public class WebConfig {

@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOriginPattern("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");

source.registerCorsConfiguration("/api/**", config);
return new CorsFilter(source);
}
// @Bean
// public CorsFilter corsFilter() {
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
// CorsConfiguration config = new CorsConfiguration();
// config.setAllowCredentials(true);
// config.addAllowedOriginPattern("*");
// config.addAllowedHeader("*");
// config.addAllowedMethod("*");
//
// source.registerCorsConfiguration("/api/**", config);
// return new CorsFilter(source);
// }
}

0 comments on commit 0f7e689

Please sign in to comment.