Q1. What are Route Handlers and how do they differ from API Routes?
Route Handlers live in app/api/.../route.ts and export HTTP-method functions such as GET, POST, PUT, DELETE and PATCH. They receive a standard Request and return a Respon...
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (16 available).
Route Handlers live in app/api/.../route.ts and export HTTP-method functions such as GET, POST, PUT, DELETE and PATCH. They receive a standard Request and return a Respon...
A feature to create API endpoints in the `pages/api` or `app/api` directory. It allow you to create custom request handlers for a given route using the Web Request and Re...
Next.js provides built-in serverless backend capabilities for creating REST or GraphQL endpoints: ### 1. In App Router (Route Handlers - Modern): Create a `route.ts` (or ...
By setting appropriate headers in the API route response. ```js export default function handler(req, res) { res.setHeader("Access-Control-Allow-Origin", "*"); res.setHead...
To prevent API routes from being accessed by the client, you can implement authentication and authorization checks in your API route handlers. This ensures that only auth...
You can opt into the Edge Runtime to run API routes on the V8/edge environment. Add `export const runtime = "edge";` at the top of a route handler and use the Web `Reques...
For basic protection you can use an in-memory store (suitable for single-instance apps) or a shared store (Redis) for multiple instances. Example memory-based limiter usi...
By creating files in the `pages/api` directory, which will be treated as API endpoints. ```jsx // pages/api/hello.js export default function handler(req, res) { res.statu...
In the Next.js App Router, you can use the `fetch` API to make HTTP requests to external APIs or your own API routes. The `fetch` function is available globally in both s...
In the App Router, API routes are now called "Route Handlers" and use the `route.js` file convention instead of the pages-based approach. **Pages Router (API Routes)**: `...
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.