Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.withtime.be.withtimebe.global.data;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "cors")
public class CorsConfigData {
private List<String> urls;
private List<String> methods;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.withtime.be.withtimebe.domain.auth.service.query.TokenStorageQueryService;
import org.withtime.be.withtimebe.domain.member.service.query.MemberQueryService;
import org.withtime.be.withtimebe.global.data.CorsConfigData;
import org.withtime.be.withtimebe.global.security.filter.JsonLoginFilter;
import org.withtime.be.withtimebe.global.security.filter.JwtFilter;
import org.withtime.be.withtimebe.global.security.handler.CustomAccessDeniedHandler;
Expand All @@ -47,6 +48,7 @@ public class SecurityConfig {
private final MemberQueryService memberQueryService;
private final JwtUtil jwtUtil;
private final FailureResponseWriter<DefaultResponseErrorReasonDTO> failureResponseWriter;
private final CorsConfigData corsConfigData;

private String[] allowUrl = {
API_PREFIX + "/auth/**",
Expand Down Expand Up @@ -145,9 +147,9 @@ PasswordEncoder passwordEncoder() {
private CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

configuration.addAllowedOriginPattern("http://localhost:5173"); // 싀배포 μ£Όμ†Œ λ‚˜μ€‘μ— μΆ”κ°€
corsConfigData.getUrls().forEach(configuration::addAllowedOrigin); // 싀배포 μ£Όμ†Œ λ‚˜μ€‘μ— μΆ”κ°€
corsConfigData.getMethods().forEach(configuration::addAllowedMethod);
configuration.addAllowedHeader("*");
configuration.addAllowedMethod("*");
configuration.setAllowCredentials(true);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/application-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ spring:
token-uri: https://oauth2.googleapis.com/token
user-info-uri: https://www.googleapis.com/userinfo/v2/me

firebase:
enabled: true
config: ${FIREBASE_CONFIG}

cors:
urls:
- http://localhost:8080
- http://localhost:3000
- http://localhost:5173
- http://localhost:5174
- https://withtime.cloud

methods:
- GET
- POST
- PUT
- PATCH
- DELETE

jwt:
secret: ${JWT_SECRET}
time:
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ spring:
enabled: true
config: ${FIREBASE_CONFIG}

cors:
urls:
- http://localhost:8080
- http://localhost:3000
- http://localhost:5173
- http://localhost:5174
- https://withtime.cloud

methods:
- GET
- POST
- PUT
- PATCH
- DELETE

jwt:
secret: ${JWT_SECRET}
time:
Expand Down