Skip to content

Commit

Permalink
추가: 환경변수 적용 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Jun 1, 2024
1 parent 05479b5 commit c94cbda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ server:
swagger:
host: www.ticats.site
protocol: https

firebase:
key: ${FCM_SECRET}

0 comments on commit c94cbda

Please sign in to comment.