diff --git a/src/main/java/project/backend/global/config/FirebaseConfig.java b/src/main/java/project/backend/global/config/FirebaseConfig.java index 7403aa3..aab5826 100644 --- a/src/main/java/project/backend/global/config/FirebaseConfig.java +++ b/src/main/java/project/backend/global/config/FirebaseConfig.java @@ -5,6 +5,7 @@ import com.google.firebase.FirebaseOptions; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,14 +15,16 @@ @Configuration public class FirebaseConfig { + @Value("${firebase.key}") + private String fcmSecretKey; + @Bean public FirebaseApp initializeFirebaseApp() throws IOException { - String firebaseConfig = System.getenv("FCM_SECRET"); - if (firebaseConfig == null) { + if (fcmSecretKey == null) { throw new IOException("FCM_SECRET environment variable is not set."); } - ByteArrayInputStream serviceAccount = new ByteArrayInputStream(firebaseConfig.getBytes()); + ByteArrayInputStream serviceAccount = new ByteArrayInputStream(fcmSecretKey.getBytes()); FirebaseOptions options = new FirebaseOptions.Builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ca34854..a607395 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -77,3 +77,6 @@ server: swagger: host: www.ticats.site protocol: https + +firebase: + key: ${FCM_SECRET}