-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
_app.tsx
26 lines (20 loc) · 766 Bytes
/
_app.tsx
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
import '../styles/globals.css';
import axios from 'axios';
import type { AppProps } from 'next/app';
import { useEffect, useState } from 'react';
function MyApp({ Component, pageProps }: AppProps) {
const [isHashValid, setIsHashValid] = useState(false);
// Wait for validation to complete before rendering the page and stop the
// rendering if the hash is invalid. Comment out the following useEffect
// hook to see the page render without the hash validation.
useEffect(() => {
axios
.post('/api/validate-hash', { hash: window.Telegram.WebApp.initData })
.then((response) => setIsHashValid(response.status === 200));
}, []);
if (!isHashValid) {
return null;
}
return <Component {...pageProps} />;
}
export default MyApp;