diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c439eb..8a54325 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,26 +25,24 @@ jobs: - name: Build with Gradle (skip test) run: ./noonsongmaker/gradlew -p noonsongmaker clean build -x test - - name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - - - name: Test EC2 host value - run: ping -c 2 ${{ secrets.EC2_HOST }} - - - name: Add EC2 host to known_hosts - run: ssh-keyscan ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts - - - name: Upload JAR to EC2 - run: | - scp -i ~/.ssh/id_rsa -P ${{ secrets.EC2_PORT }} noonsongmakerbuild/libs/noonsongmaker-0.0.1-SNAPSHOT.jar ${{ secrets.EC2_HOST }}:/home/ec2-user/build/libs/ - - - name: Restart docker-compose on EC2 - run: | - ssh -i ~/.ssh/id_rsa -p ${{ secrets.EC2_PORT }} ${{ secrets.EC2_HOST }} << 'EOF' + - name: SCP + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + source: noonsongmaker/build/libs/noonsongmaker-0.0.1-SNAPSHOT.jar + target: /home/ec2-user/build/libs + strip_components: 3 + + - name: SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + script_stop: true + script: | cd /home/ec2-user docker-compose down docker-compose up -d - EOF diff --git a/noonsongmaker/src/main/java/sookmyung/noonsongmaker/Config/SecurityConfig.java b/noonsongmaker/src/main/java/sookmyung/noonsongmaker/Config/SecurityConfig.java index c72c987..f20c525 100644 --- a/noonsongmaker/src/main/java/sookmyung/noonsongmaker/Config/SecurityConfig.java +++ b/noonsongmaker/src/main/java/sookmyung/noonsongmaker/Config/SecurityConfig.java @@ -49,6 +49,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .requireExplicitSave(false) // SecurityContext 자동 저장 활성화 ) .authorizeHttpRequests(auth -> auth + .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .requestMatchers("/auth/logout", "/auth/login", "/auth/signup", "/auth/verify-code", "/auth/send-email","/intro/info-new", "/auth/refresh", "/sse/subscribe/{userId}").permitAll() .anyRequest().authenticated() @@ -82,7 +83,7 @@ public Filter jwtAuthorizeFilter(JwtProvider jwtProvider, UserRepository userRep public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowCredentials(true); // 인증 정보 포함할 경우 true - configuration.setAllowedOriginPatterns(List.of("http://localhost:5173", "http://localhost:8080", "http://52.79.237.120:8080")); // 프론트엔드 주소 + configuration.setAllowedOriginPatterns(List.of("http://localhost:5173", "http://localhost:8080", "http://52.79.237.120:8080", "https://snowflakemaker.netlify.app", "https://nsmaker.o-r.kr")); // 프론트엔드 주소 configuration.setAllowedHeaders(List.of("*")); configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH")); configuration.setExposedHeaders(List.of("Content-Type"));