Skip to content

Commit

Permalink
Refactor allow method origin
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkhanh-axonivy committed Jul 24, 2024
1 parent cf28b8e commit 3c71dec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class WebConfig implements WebMvcConfigurer {
private static final String[] EXCLUDE_PATHS = { "/", "/swagger-ui/**", "/api-docs/**" };
private static final String[] ALLOWED_HEADERS = { "Accept-Language", "Content-Type", "Authorization",
"X-Requested-By", "x-requested-with", "X-Forwarded-Host", "x-xsrf-token" };
private static final String[] ALLOWED_METHODS = { "GET", "OPTIONS", "POST" };
private static final String[] ALLOWED_METHODS = { "GET", "OPTIONS" };

private final MarketHeaderInterceptor headerInterceptor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -76,6 +77,7 @@ public ResponseEntity<FeedbackModel> findFeedbackByUserIdAndProductId(@RequestPa
return ResponseEntity.ok(feedbackModelAssembler.toModel(feedback));
}

@CrossOrigin("*")
@PostMapping
public ResponseEntity<Void> createFeedback(@RequestBody @Valid FeedbackModel feedback,
@RequestHeader(value = "Authorization", required = false) String authorizationHeader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.axonivy.market.service.JwtService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -34,6 +35,7 @@ public OAuth2Controller(GitHubService gitHubService, JwtService jwtService) {
this.jwtService = jwtService;
}

@CrossOrigin("*")
@PostMapping("/github/login")
public ResponseEntity<Object> gitHubLogin(@RequestBody Oauth2AuthorizationCode oauth2AuthorizationCode) {
GitHubAccessTokenResponse tokenResponse = gitHubService.getAccessToken(oauth2AuthorizationCode.getCode(), clientId,
Expand Down

0 comments on commit 3c71dec

Please sign in to comment.