route.ts 805 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { NextResponse, NextRequest } from "next/server";
  2. import { restApiFetch } from "@/utils/bagisto";
  3. // http://nshop.test/api/customer/check-email?email=bb@tt.com
  4. export async function GET(request: NextRequest) {
  5. try {
  6. const searchParams = request.nextUrl.searchParams;
  7. const email = searchParams.get('email');
  8. const response = await restApiFetch<any>({
  9. api: "/customer/check-email",
  10. method: "GET",
  11. cache: "no-store",
  12. variables: {
  13. email: email
  14. }
  15. });
  16. return NextResponse.json(
  17. response.body,
  18. {status: response.status}
  19. );
  20. } catch (error) {
  21. return NextResponse.json(
  22. {
  23. message: "Network error",
  24. error: error instanceof Error ? error.message : error,
  25. },
  26. { status: 500 }
  27. );
  28. }
  29. }