Skip to content

Commit

Permalink
Feat: CORS 기능 추가 (시스템 환경변수 활용하여 LOCAL_IP, AWS_IP 추가)
Browse files Browse the repository at this point in the history
- 환경변수로 LOCAl_IP, AWS_IP 추가해야함
  • Loading branch information
ku-kim committed Apr 26, 2022
1 parent 9f62389 commit b67ecc9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions BE/src/main/java/sidedish/com/config/WebConfig.java
@@ -0,0 +1,20 @@
package sidedish.com.config;

import java.util.Map;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
Map<String, String> envs = System.getenv();
String awsIp = "http://" + envs.get("AWS_IP");
String localIp = "http://" + envs.get("LOCAL_IP");

registry.addMapping("/**")
.allowedOrigins(localIp, awsIp);
}
}
2 changes: 1 addition & 1 deletion BE/src/main/resources/application-prod.yml
@@ -1,6 +1,6 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${MYSQL_DATABASE}
url: jdbc:mysql://${MYSQL_DATABASE}
username: ${MYSQL_USER}
password: ${MYSQL_PASSWORD}

0 comments on commit b67ecc9

Please sign in to comment.