Problem Statement
Where do you create API routes in the Pages Router?
Explanation
API routes are created inside the pages/api directory where each file becomes an API endpoint, with pages/api/hello.js creating the /api/hello endpoint automatically. API route files export a default function that receives request and response objects similar to Express.js, allowing you to handle different HTTP methods, parse request bodies, set response status and headers, and implement backend logic. These routes run only on the server, never in the browser, making them perfect for handling sensitive operations, database queries, or third-party API calls with secret keys.
