Skip to content

Commit

Permalink
Merge pull request #145 from Malcom1986/cors
Browse files Browse the repository at this point in the history
close#142 Fix cors error
  • Loading branch information
fey committed Apr 24, 2023
2 parents 5652999 + ef9c7c2 commit de08fe5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Expand Up @@ -68,6 +68,7 @@ public SecurityContextRepository securityContextRepository() {
public SecurityFilterChain filterChain(HttpSecurity http,
SecurityContextRepository securityContextRepository) throws Exception {
http.httpBasic();
http.cors();

http.authorizeHttpRequests(authz -> authz
.requestMatchers(GET, "/webjars/**", "/widget/**", "/img/**").permitAll()
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/hexlet/typoreporter/web/WorkspaceApi.java
Expand Up @@ -13,6 +13,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.web.bind.annotation.CrossOrigin;

import static org.springframework.http.ResponseEntity.created;

Expand All @@ -24,6 +25,11 @@ public class WorkspaceApi {
private final TypoService service;

@PostMapping("/typos")
// TODO: allow sending a request only from the pages specified in the Workspace settings
@CrossOrigin(
originPatterns = {"*"},
allowCredentials = "true"
)
public ResponseEntity<ReportedTypo> addTypoReport(Authentication authentication,
@Valid @RequestBody TypoReport typoReport,
UriComponentsBuilder builder) {
Expand Down

0 comments on commit de08fe5

Please sign in to comment.