This is the code placed inside /app/api/password/reset/confirm/[userId]/[idToken]/route.ts.
import { NextRequest, NextResponse } from 'next/server';
// Define and export the GET handler
export const GET = async (request: NextRequest, context: { params: { userId: number; idToken: string } }) => {
const { userId, idToken } = context.params;
const userID : number = 1
const IDToken : string = "c8jzmm-8e51a9981443975cf764d26ddb20093a"
if (userId === userID && idToken === IDToken) {
// Return a response if the token is valid
return NextResponse.json({ message: 'Password reset link is valid', userId, idToken });
} else {
// Return an error response if the token is invalid
return NextResponse.json({ message: 'Invalid password reset link' }, { status: 400 });
}
};
This is what error message I getting if I'm doing a request from browser or from Terminal.
GET /api/password/reset/confirm/1/c8jzmm-8e51a9981443975cf764d26ddb20093a 405 in 17ms
⨯ No HTTP methods exported in ‘/home/code/Documents/playground/frontend/projects/signupwithallauth/app/api/password/reset/confirm/[userId]/[idToken]/route.ts’. Export a named export for each HTTP method.
below is the http request made from terminal,
code@code:~$ http GET http://localhost:3000/api/password/reset/confirm/1/c8jzmm-8e51a9981443975cf764d26ddb20093a
HTTP/1.1 405 Method Not Allowed
Connection: keep-alive
Date: Sat, 15 Jun 2024 08:17:48 GMT
Keep-Alive: timeout=5
Transfer-Encoding: chunked
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch
If the dynamic routes working fine then, the route.ts file should return any response other than 405 Method Not Allowed.