Skip to content

Commit 1608e41

Browse files
committed
added layout
1 parent a65696c commit 1608e41

File tree

4 files changed

+103
-16
lines changed

4 files changed

+103
-16
lines changed

package-lock.json

Lines changed: 37 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"dependencies": {
2020
"@elastic/elasticsearch": "^8.9.0",
21-
"@emotion/react": "^11.11.1",
21+
"@emotion/cache": "^11.11.0",
22+
"@emotion/react": "^11.11.4",
2223
"@emotion/styled": "^11.11.0",
2324
"@fontsource/inter": "^5.0.7",
2425
"@mui/base": "^5.0.0-beta.11",
@@ -51,6 +52,7 @@
5152
"react": "18.2.0",
5253
"react-date-range": "^1.4.0",
5354
"react-dom": "18.2.0",
55+
"react-google-recaptcha-v3": "^1.10.1",
5456
"react-leaflet": "^4.2.1",
5557
"react-leaflet-cluster": "^2.1.0",
5658
"react-object-view": "^0.3.4",

src/app/layout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// app/ThemeRegistry.tsx
22
'use client';
33

4+
import { GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
45
import './globals.scss'
56
import type { Metadata } from 'next'
67
import { Inter } from 'next/font/google'
@@ -97,13 +98,17 @@ const ThemeRegistry = (props: ThemeProps) => {
9798

9899

99100
return (
101+
102+
103+
<GoogleReCaptchaProvider reCaptchaKey={process.env.NEXT_GOOGLE_V3_SITE ?? ""}>
100104
<CacheProvider value={cache}>
101105
<CssVarsProvider theme={customTheme}>
102106
{/* the custom theme is optional */}
103107
<CssBaseline />
104108
{children}
105109
</CssVarsProvider>
106110
</CacheProvider>
111+
</GoogleReCaptchaProvider>
107112
);
108113
}
109114

src/middleware.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { NextResponse } from 'next/server'
2+
import type { NextRequest } from 'next/server'
3+
4+
5+
// const allowedOrigins = ['https://acme.com', 'https://my-app.org']
6+
7+
// This function can be marked `async` if using `await` inside
8+
export async function middleware(request: NextRequest) {
9+
10+
// Check the origin from the request
11+
const origin = request.headers.get('origin') ?? ''
12+
const host = request.headers.get('host') ?? ''
13+
14+
const token = request.headers.get('g-token') ?? '';
15+
16+
console.log("middleware: ", origin, " host: ", token)
17+
18+
// if (token) {
19+
// var responseData = await fetch('https://www.google.com/recaptcha/api/siteverify?' + new URLSearchParams({
20+
// secret: process.env.NEXT_GOOGLE_V3_SECRET ?? "",
21+
// response: token,
22+
// }), {
23+
// method: 'POST',
24+
// headers: {
25+
// 'Content-Type': 'application/json'
26+
// },
27+
28+
// })
29+
// var captchaResponse = await responseData.json()
30+
31+
// if (!captchaResponse['success']) {
32+
// return NextResponse.json({ message: 'Auth invalid' }, { status: 401 });
33+
34+
// }
35+
// }else {
36+
// return NextResponse.json({ message: 'Auth required' }, { status: 401 });
37+
38+
// }
39+
40+
41+
42+
const response = NextResponse.next()
43+
44+
// if (isAllowedOrigin) {
45+
// response.headers.set('Access-Control-Allow-Origin', origin)
46+
// }
47+
48+
// Object.entries(corsOptions).forEach(([key, value]) => {
49+
// response.headers.set(key, value)
50+
// })
51+
52+
return response
53+
}
54+
55+
// See "Matching Paths" below to learn more
56+
export const config = {
57+
matcher: '/api/:path*',
58+
}

0 commit comments

Comments
 (0)