Skip to content

Commit

Permalink
Merge pull request #41 from Louie-03/BE-feature-CORS
Browse files Browse the repository at this point in the history
[BE] CORS 기능 추가 (시스템 환경변수 활용)
  • Loading branch information
Louie-03 committed Apr 26, 2022
2 parents b8753ad + b67ecc9 commit 3375244
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 3375244

Please sign in to comment.