-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathApp.jsx
57 lines (52 loc) · 1.62 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { useState } from "react";
import {
getFunctions,
httpsCallable,
connectFunctionsEmulator,
} from "firebase/functions";
import { initializeApp } from "firebase/app";
import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
import "./App.css";
function App() {
const app = initializeApp({
// Your Firebase app configs here
apiKey: "AIzaSyBk-u6F9UAesAwj7NQh80Rlr-AHc69UtOY",
authDomain: "rc-strawberry.firebaseapp.com",
projectId: "rc-strawberry",
storageBucket: "rc-strawberry.appspot.com",
messagingSenderId: "105225960024",
appId: "1:105225960024:web:a2c70ff84e835a7d22682d",
});
// Set up App Check according to https://firebase.google.com/docs/app-check/web/recaptcha-enterprise-provider
if (process.env.NODE_ENV !== "production") {
// Local testing
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
}
const APP_CHECK_TOKEN = "APP_CHECK_TOKEN";
initializeAppCheck(app, {
provider: new ReCaptchaEnterpriseProvider(APP_CHECK_TOKEN),
isTokenAutoRefreshEnabled: true,
});
const functions = getFunctions();
connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const callGemini = httpsCallable(functions, "callGemini");
const [geminiResponse, setGeminiResponse] = useState();
return (
<>
<div>
<button
onClick={() =>
callGemini().then((result) => {
const data = result.data;
setGeminiResponse(data);
})
}
>
Call Gemini
</button>
<p>{JSON.stringify(geminiResponse?.text)}</p>
</div>
</>
);
}
export default App;