백엔드 서비스 설정 및 CORS 정책 업데이트
- CORS 설정에 https 프로토콜 지원 추가 - User-Service CORS를 모든 Origin 허용으로 변경 - ConfigMap CORS_ALLOWED_ORIGINS 확장 - User-Service DB migration 스크립트 추가 - Application 설정 파일 업데이트 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
857fa5501c
commit
e8d0a1d4b4
@ -20,7 +20,7 @@ data:
|
||||
EXCLUDE_REDIS: ""
|
||||
|
||||
# CORS Configuration
|
||||
CORS_ALLOWED_ORIGINS: "http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io"
|
||||
CORS_ALLOWED_ORIGINS: "http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io,http://kt-event-marketing-api.20.214.196.128.nip.io,http://*.20.214.196.128.nip.io,https://kt-event-marketing.20.214.196.128.nip.io,https://kt-event-marketing-api.20.214.196.128.nip.io,https://*.20.214.196.128.nip.io"
|
||||
CORS_ALLOWED_METHODS: "GET,POST,PUT,DELETE,OPTIONS,PATCH"
|
||||
CORS_ALLOWED_HEADERS: "*"
|
||||
CORS_ALLOW_CREDENTIALS: "true"
|
||||
|
||||
@ -98,4 +98,14 @@ management:
|
||||
livenessState:
|
||||
enabled: true
|
||||
readinessState:
|
||||
enabled: true
|
||||
enabled: true
|
||||
|
||||
# OpenAPI Documentation
|
||||
springdoc:
|
||||
api-docs:
|
||||
path: /v3/api-docs
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
show-actuator: false
|
||||
@ -12,6 +12,10 @@ dependencies {
|
||||
// OpenFeign for external API calls (사업자번호 검증)
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
|
||||
|
||||
// Flyway for database migration
|
||||
implementation 'org.flywaydb:flyway-core'
|
||||
implementation 'org.flywaydb:flyway-database-postgresql'
|
||||
|
||||
// H2 Database for development
|
||||
runtimeOnly 'com.h2database:h2'
|
||||
|
||||
|
||||
@ -65,18 +65,14 @@ public class SecurityConfig {
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
|
||||
// 환경변수에서 허용할 Origin 패턴 설정
|
||||
String[] origins = allowedOrigins.split(",");
|
||||
configuration.setAllowedOriginPatterns(Arrays.asList(origins));
|
||||
// 모든 Origin 허용
|
||||
configuration.setAllowedOriginPatterns(Arrays.asList("*"));
|
||||
|
||||
// 허용할 HTTP 메소드
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
|
||||
|
||||
// 허용할 헤더
|
||||
configuration.setAllowedHeaders(Arrays.asList(
|
||||
"Authorization", "Content-Type", "X-Requested-With", "Accept",
|
||||
"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers"
|
||||
));
|
||||
configuration.setAllowedHeaders(Arrays.asList("*"));
|
||||
|
||||
// 자격 증명 허용
|
||||
configuration.setAllowCredentials(true);
|
||||
@ -84,6 +80,9 @@ public class SecurityConfig {
|
||||
// Pre-flight 요청 캐시 시간
|
||||
configuration.setMaxAge(3600L);
|
||||
|
||||
// Exposed Headers 추가
|
||||
configuration.setExposedHeaders(Arrays.asList("Authorization", "Content-Type"));
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
return source;
|
||||
|
||||
@ -31,7 +31,13 @@ spring:
|
||||
use_sql_comments: true
|
||||
dialect: ${JPA_DIALECT:org.hibernate.dialect.PostgreSQLDialect}
|
||||
hibernate:
|
||||
ddl-auto: ${DDL_AUTO:update}
|
||||
ddl-auto: ${DDL_AUTO:validate}
|
||||
|
||||
# Flyway Configuration
|
||||
flyway:
|
||||
enabled: ${FLYWAY_ENABLED:true}
|
||||
baseline-on-migrate: ${FLYWAY_BASELINE:true}
|
||||
locations: classpath:db/migration
|
||||
|
||||
# Auto-configuration exclusions for development without external services
|
||||
autoconfigure:
|
||||
@ -76,7 +82,7 @@ jwt:
|
||||
|
||||
# CORS Configuration
|
||||
cors:
|
||||
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io}
|
||||
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io,http://kt-event-marketing-api.20.214.196.128.nip.io,http://*.kt-event-marketing-api.20.214.196.128.nip.io,http://*.20.214.196.128.nip.io}
|
||||
allowed-methods: ${CORS_ALLOWED_METHODS:GET,POST,PUT,DELETE,OPTIONS,PATCH}
|
||||
allowed-headers: ${CORS_ALLOWED_HEADERS:*}
|
||||
allow-credentials: ${CORS_ALLOW_CREDENTIALS:true}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
-- Migration script to change user_id from BIGINT to UUID
|
||||
-- WARNING: This will delete all existing data in users and stores tables
|
||||
-- Make sure to backup your data before running this script!
|
||||
|
||||
-- Step 1: Drop dependent tables/constraints
|
||||
DROP TABLE IF EXISTS stores CASCADE;
|
||||
DROP TABLE IF EXISTS users CASCADE;
|
||||
|
||||
-- Step 2: Create users table with UUID
|
||||
CREATE TABLE users (
|
||||
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(50) NOT NULL,
|
||||
phone_number VARCHAR(20) NOT NULL UNIQUE,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
role VARCHAR(20) NOT NULL DEFAULT 'OWNER',
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
|
||||
last_login_at TIMESTAMP,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Step 3: Create indexes on users table
|
||||
CREATE UNIQUE INDEX idx_user_phone ON users(phone_number);
|
||||
CREATE UNIQUE INDEX idx_user_email ON users(email);
|
||||
|
||||
-- Step 4: Create stores table with UUID foreign key
|
||||
CREATE TABLE stores (
|
||||
store_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(100) NOT NULL,
|
||||
industry VARCHAR(50),
|
||||
address VARCHAR(255) NOT NULL,
|
||||
business_hours VARCHAR(255),
|
||||
user_id UUID NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_stores_user FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Step 5: Create index on stores table
|
||||
CREATE INDEX idx_stores_user ON stores(user_id);
|
||||
|
||||
-- Enable UUID extension if not already enabled
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
||||
@ -0,0 +1,45 @@
|
||||
-- Migration script V002: Change user_id and store_id from BIGINT to UUID
|
||||
-- WARNING: This will delete all existing data in users and stores tables
|
||||
-- Make sure to backup your data before running this script!
|
||||
|
||||
-- Step 1: Drop dependent tables/constraints
|
||||
DROP TABLE IF EXISTS stores CASCADE;
|
||||
DROP TABLE IF EXISTS users CASCADE;
|
||||
|
||||
-- Step 2: Create users table with UUID
|
||||
CREATE TABLE users (
|
||||
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(50) NOT NULL,
|
||||
phone_number VARCHAR(20) NOT NULL UNIQUE,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
role VARCHAR(20) NOT NULL DEFAULT 'OWNER',
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
|
||||
last_login_at TIMESTAMP,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Step 3: Create indexes on users table
|
||||
CREATE UNIQUE INDEX idx_user_phone ON users(phone_number);
|
||||
CREATE UNIQUE INDEX idx_user_email ON users(email);
|
||||
|
||||
-- Step 4: Create stores table with UUID foreign key
|
||||
CREATE TABLE stores (
|
||||
store_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(100) NOT NULL,
|
||||
industry VARCHAR(50),
|
||||
address VARCHAR(255) NOT NULL,
|
||||
business_hours VARCHAR(255),
|
||||
user_id UUID NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_stores_user FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Step 5: Create index on stores table
|
||||
CREATE INDEX idx_stores_user ON stores(user_id);
|
||||
|
||||
-- Enable UUID extension if not already enabled
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
||||
Loading…
x
Reference in New Issue
Block a user