@@ -3,8 +3,16 @@ import { NextRequest, NextResponse } from 'next/server'
33
44const EXTERNAL_API_URL = process . env . NEXT_PUBLIC_API_URL
55
6- export async function GET ( request : NextRequest ) {
6+ /**
7+ * Handles GET requests by forwarding them to an external API.
8+ * Retrieves the current session and uses the access token for authorization.
9+ *
10+ * @param {NextRequest } request - The incoming request object from Next.js.
11+ * @returns {Promise<Response> } - The response from the external API or an error response.
12+ */
13+ export async function GET ( request : NextRequest ) : Promise < Response > {
714 const session = await getSession ( )
15+ console . log ( 'GET' )
816 const path = request . nextUrl . pathname
917 console . log ( `${ EXTERNAL_API_URL } ${ path } ${ request . nextUrl . search } ` )
1018 try {
@@ -20,6 +28,13 @@ export async function GET(request: NextRequest) {
2028 }
2129}
2230
31+ /**
32+ * Handles POST requests by forwarding them to an external API.
33+ * Retrieves the current session and uses the access token for authorization.
34+ *
35+ * @param {NextRequest } request - The incoming request object from Next.js.
36+ * @returns {Promise<Response> } - The response from the external API.
37+ */
2338export async function POST ( request : NextRequest ) {
2439 const session = await getSession ( )
2540 const path = request . nextUrl . pathname
@@ -36,6 +51,13 @@ export async function POST(request: NextRequest) {
3651 } as any )
3752}
3853
54+ /**
55+ * Handles PUT requests by forwarding them to an external API.
56+ * Retrieves the current session and uses the access token for authorization.
57+ *
58+ * @param {NextRequest } request - The incoming request object from Next.js.
59+ * @returns {Promise<Response> } - The response from the external API.
60+ */
3961export async function PUT ( request : NextRequest ) {
4062 const session = await getSession ( )
4163 const path = request . nextUrl . pathname
@@ -52,8 +74,14 @@ export async function PUT(request: NextRequest) {
5274 } as any )
5375}
5476
77+ /**
78+ * Handles DELETE requests by forwarding them to an external API.
79+ * Retrieves the current session and uses the access token for authorization.
80+ *
81+ * @param {NextRequest } request - The incoming request object from Next.js.
82+ * @returns {Promise<Response> } - The response from the external API.
83+ */
5584export async function DELETE ( request : NextRequest ) {
56- // reroute the request to the API
5785 const session = await getSession ( )
5886 const path = request . nextUrl . pathname
5987 const url = `${ EXTERNAL_API_URL } ${ path } ${ request . nextUrl . search } `
@@ -65,4 +93,4 @@ export async function DELETE(request: NextRequest) {
6593 __tenant : session . tenantId === 'default' ? undefined : session . tenantId ,
6694 } as any ,
6795 } )
68- }
96+ }
0 commit comments