-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathMvcConfiguration.java
More file actions
29 lines (24 loc) · 1 KB
/
Copy pathMvcConfiguration.java
File metadata and controls
29 lines (24 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.gmail.merikbest2015.twitterspringreactjs.configuration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfiguration implements WebMvcConfigurer {
@Value("${host.name}")
private String hostname;
@Bean
public RestTemplate getRestTemplate() {
return new RestTemplate();
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/v1/**")
.allowedOrigins("http://" + hostname)
.allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE")
.exposedHeaders("page-total-count")
.allowedHeaders("*");
}
}