BAEL-3724: Add cross origin requests processing config (#8770)
This commit is contained in:
parent
36474ca59f
commit
0568f91ae7
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class AccountController {
|
public class AccountController {
|
||||||
|
|
||||||
@CrossOrigin("http://example.com")
|
@CrossOrigin("http://example.com")
|
||||||
@RequestMapping("/{id}")
|
@RequestMapping(method = RequestMethod.GET, path = "/{id}")
|
||||||
public Account retrieve(@PathVariable Long id) {
|
public Account retrieve(@PathVariable Long id) {
|
||||||
return new Account(id);
|
return new Account(id);
|
||||||
}
|
}
|
||||||
|
@ -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("/**");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user