Skip to content

Commit

Permalink
feat: 환경변수 개발환경 별도 설정 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
SHEOMM authored Apr 2, 2024
1 parent ef8eea4 commit c3e920c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public CurrentSessionAttendeeAttendance getCurrentSessionAttendanceInfo(String a
absentees.add(att);
}
});

return CurrentSessionAttendeeAttendance.builder()
.attendees(attendees)
.absentees(absentees)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.waruru.areyouhere.auth.resolver.LoginArgumentResolver;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
Expand All @@ -17,6 +18,9 @@ public class WebConfig implements WebMvcConfigurer {
private final LoginInterceptor loginInterceptor;
private final LoginArgumentResolver loginArgumentResolver;

@Value("${cors.allowed-origins}")
private String[] allowedOrigins;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor);
Expand All @@ -29,8 +33,11 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)

@Override
public void addCorsMappings(CorsRegistry registry) {



registry.addMapping("/**")
.allowedOrigins("http://localhost:5173")
.allowedOrigins(allowedOrigins)
.allowedMethods("GET","POST", "PUT", "DELETE", "OPTIONS", "HEAD")
.allowCredentials(true)
.maxAge(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public List<SessionAttendanceInfo> getRecentFive(Long courseId){
@Override
public List<SessionAttendanceInfo> getAll(Long courseId){
List<SessionInfo> allSessions = sessionRepository.findSessionsWithAttendance(courseId);

return allSessions == null || allSessions.isEmpty()
? Collections.emptyList()
: allSessions.stream().map(allSession -> SessionAttendanceInfo.builder()
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ spring:
logging:
level:
root: info

cors:
allowed-origins: http://localhost:5173
15 changes: 10 additions & 5 deletions src/main/resources/application-temp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ spring.config.activate.on-profile: temp
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/areyouhere?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=Asia/Seoul&CharacterEncoding=UTF-8
username: root
password: temporary
url: ${MYSQL_DATASOURCE_URL}
username: ${MYSQL_DATASOURCE_USERNAME}
password: ${ MYSQL_DATASOURCE_PASSWORD }
jpa:
show-sql: true
hibernate:
Expand All @@ -16,5 +16,10 @@ spring:
database: mysql
data:
redis:
host: localhost
port: 6379
host: ${ REDIS_DATASOURCE_HOST }
port: ${ REDIS_DATASOURCE_PORT }


cors:
allowed-origins: https://areyouhere.today, https://www.areyouhere.today

0 comments on commit c3e920c

Please sign in to comment.