BAEL-3724: Add cross origin requests processing config (#8770)

This commit is contained in:
kwoyke 2020-02-29 21:33:10 +01:00 committed by GitHub
parent 36474ca59f
commit 0568f91ae7
2 changed files with 17 additions and 1 deletions

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
public class AccountController {
@CrossOrigin("http://example.com")
@RequestMapping("/{id}")
@RequestMapping(method = RequestMethod.GET, path = "/{id}")
public Account retrieve(@PathVariable Long id) {
return new Account(id);
}

View File

@ -0,0 +1,16 @@
package com.baeldung.cors.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}