Q21. How can you implement simple rate limiting for API routes?
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...
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 (79 available).
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...
The Pages Router is a file-based routing system in Next.js that automatically creates routes based on the file structure inside the `pages` directory.
In Next.js pages router, you create routes by adding files to the `pages` directory: - `pages/index.js` - the homepage (/) - `pages/about.js` - the about page (/about) - ...
In the pages directory, you can add bracket syntax to create dynamic routes: ```jsx pages/posts/[id].js → /posts/1, /posts/2, etc. pages/[username]/settings.js → /foo/set...
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...
Yes, the Pages Router has some limitations compared to the App Router, such as: - Limited support for nested routes and layouts. - Less flexibility in handling server com...
By using libraries like `next-auth` or implementing custom authentication logic in API routes. ```jsx // pages/api/auth/[...nextauth].js import NextAuth from "next-auth";...
By creating a custom server or using API routes to implement middleware logic. ```js // pages/api/middleware.js export default function middleware(req, res, next) { // Cu...
By using client-side form handling or API routes for server-side handling. ```jsx // pages/contact.js export default function Contact() { const handleSubmit = async (e) =...
Yes, you can use features like static generation (SSG), server-side rendering (SSR), and incremental static regeneration (ISR) to optimize performance in the Pages Router...
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.