Skip to content

Commit

Permalink
refac:added .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
anwesha authored and anwesha committed Sep 20, 2024
1 parent 965e804 commit 113ad09
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
10 changes: 9 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
REACT_APP_API_KEY=AIzaSyCNLCghPaaEOQ6sRTIcU5MUnAWCbEEufBQ
REACT_APP_API_KEY=AIzaSyCNLCghPaaEOQ6sRTIcU5MUnAWCbEEufBQ

REACT_APP_APILEY: "AIzaSyA4NTAh8c0RsJp7Nxh6nnBgo4_gVElrC6s"
REACT_APP_AUTHDOMAIN: "counselor-web.firebaseapp.com"
REACT_APP_PROJECTID: "counselor-web"
REACT_APP_STORAGEBUCKET: "counselor-web.appspot.com"
REACT_APP_MESSAGING_SENDER_ID: "417914818263"
REACT_APP_APPID: "1:417914818263:web:35f0cadde168b5ae052a92"
REACT_APP_MEASUREMENT_ID: "G-68D1EM7658"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

.env
node_modules
dist
dist-ssr
Expand Down
2 changes: 1 addition & 1 deletion src/Data/fetchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import axios from "axios";
export const FetchApi = axios.create({
baseURL:"https://youtube.googleapis.com/youtube/v3",
params:{
key : "AIzaSyBbVmPvtpFZ5MqyVdGzPFaKzU0scOL7OXs"
key : process.env.REACT_APP_API_KEY
}
})
17 changes: 9 additions & 8 deletions src/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import firebase from "firebase/compat/app";
import 'firebase/compat/auth'

const app = firebase.initializeApp({
apiKey: "AIzaSyA4NTAh8c0RsJp7Nxh6nnBgo4_gVElrC6s",
authDomain: "counselor-web.firebaseapp.com",
projectId: "counselor-web",
storageBucket: "counselor-web.appspot.com",
messagingSenderId: "417914818263",
appId: "1:417914818263:web:35f0cadde168b5ae052a92",
measurementId: "G-68D1EM7658"
console.log(process.env.REACT_APP_FIREBASE_CONFIG)
const app = firebase.initializeApp( {
apiKey: process.env.REACT_APP_APILEY,
authDomain: process.env.REACT_APP_AUTHDOMAIN,
projectId: process.env.REACT_APP_PROJECTID,
storageBucket: process.env.REACT_APP_STORAGEBUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_APPID,
measurementId: process.env.REACT_APP_MEASUREMENT_ID
})

export const auth = app.auth()
Expand Down
19 changes: 16 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
export default defineConfig(({mode})=>{
const env = loadEnv(mode, process.cwd(), '');
return{
define:{
'process.env.REACT_APP_APILEY': JSON.stringify(env.REACT_APP_APILEY),
'process.env.REACT_APP_AUTHDOMAIN': JSON.stringify(env.REACT_APP_AUTHDOMAIN),
'process.env.REACT_APP_PROJECTID': JSON.stringify(env.REACT_APP_PROJECTID),
'process.env.REACT_APP_STORAGEBUCKET': JSON.stringify(env.REACT_APP_STORAGEBUCKET),
'process.env.REACT_APP_MESSAGING_SENDER_ID': JSON.stringify(env.REACT_APP_MESSAGING_SENDER_ID),
'process.env.REACT_APP_APPID': JSON.stringify(env.REACT_APP_APPID),
'process.env.REACT_APP_MEASUREMENT_ID': JSON.stringify(env.REACT_APP_MEASUREMENT_ID),
'process.env.REACT_APP_API_KEY': JSON.stringify(env.REACT_APP_API_KEY)
},
plugins: [react()],
}
})

0 comments on commit 113ad09

Please sign in to comment.