Skip to content

Commit

Permalink
set up config file for more security.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesslane94 committed Sep 25, 2024
1 parent 59c9cda commit 8cf6158
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

#keys
config.js
16 changes: 2 additions & 14 deletions app/firebaseConfig.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// import { getAnalytics } from "firebase/analytics";
import { getMessaging } from "firebase/messaging";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyD2HV19HltxDAOEEePnTLUvtuLLu_QRacs",
authDomain: "my-app-5ba3e.firebaseapp.com",
projectId: "my-app-5ba3e",
storageBucket: "my-app-5ba3e.appspot.com",
messagingSenderId: "419201348623",
appId: "1:419201348623:web:206cf5bd874fa5609edf7a",
measurementId: "G-L0E257E7X9"
};
import { firebaseConfig, vapidKey } from '../my-app/config';

// Initialize Firebase
const app = initializeApp(firebaseConfig);
Expand Down
4 changes: 4 additions & 0 deletions components/sendNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Message } from "firebase-admin/messaging";
import { NextRequest, NextResponse } from "next/server";

//notification send function here
41 changes: 2 additions & 39 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
import { firebaseConfig, vapidKey } from '../my-app/config';

// Import and configure the Firebase SDK
// These scripts are made available when the app is served or deployed on Firebase Hosting
// If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup
importScripts('/__/firebase/9.2.0/firebase-app-compat.js');
importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js');
importScripts('/__/firebase/init.js');

/**
* Here is is the code snippet to initialize Firebase Messaging in the Service
* Worker when your app is not hosted on Firebase Hosting.
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here. Other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js');
// Initialize the Firebase app in the service worker by passing in
// your app's Firebase config object.
// https://firebase.google.com/docs/web/setup#config-object
firebase.initializeApp({
apiKey: 'api-key',
authDomain: 'project-id.firebaseapp.com',
databaseURL: 'https://project-id.firebaseio.com',
projectId: 'project-id',
storageBucket: 'project-id.appspot.com',
messagingSenderId: 'sender-id',
appId: 'app-id',
measurementId: 'G-measurement-id',
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();
**/

const firebaseConfig = {
apiKey: "AIzaSyD2HV19HltxDAOEEePnTLUvtuLLu_QRacs",
authDomain: "my-app-5ba3e.firebaseapp.com",
projectId: "my-app-5ba3e",
storageBucket: "my-app-5ba3e.appspot.com",
messagingSenderId: "419201348623",
appId: "1:419201348623:web:206cf5bd874fa5609edf7a",
measurementId: "G-L0E257E7X9"
};

firebase.initializeApp(firebaseConfig);

const messaging = firebase.messaging();
Expand Down

0 comments on commit 8cf6158

Please sign in to comment.