Recall & Review
beginner
What is request modification in Next.js?
Request modification means changing the details of an HTTP request before it reaches your server or API route. In Next.js, this can be done using middleware to inspect and alter requests.
Click to reveal answer
intermediate
How do you modify a request URL in Next.js middleware?
You can use the NextResponse.rewrite() method inside middleware to change the request URL, redirecting it to a different path or resource before it reaches the handler.
Click to reveal answer
beginner
Which Next.js feature allows you to run code before a request is completed to modify it?
Middleware in Next.js runs before the request completes and lets you modify the request or response, such as rewriting URLs, adding headers, or redirecting.
Click to reveal answer
intermediate
What is the difference between NextResponse.rewrite() and NextResponse.redirect() in request modification?
NextResponse.rewrite() changes the request URL internally without changing the browser's address bar, while NextResponse.redirect() sends a redirect response that changes the browser's URL.
Click to reveal answer
advanced
Can you modify request headers in Next.js middleware? How?
Yes, you can clone the request and set new headers or modify existing ones inside middleware before passing it on. This helps add authentication tokens or custom data.
Click to reveal answer
Which Next.js feature lets you modify requests before they reach your API or page?
✗ Incorrect
Middleware runs before requests complete and can modify requests or responses.
What does NextResponse.rewrite() do in Next.js middleware?
✗ Incorrect
rewrite() changes the request path internally but keeps the browser URL the same.
How can you add a custom header to a request in Next.js middleware?
✗ Incorrect
You clone the request and set headers on the clone before continuing.
Which method sends a response that changes the browser's URL in Next.js middleware?
✗ Incorrect
redirect() sends a redirect response that updates the browser URL.
Where do you place middleware files in a Next.js project?
✗ Incorrect
Middleware files go at the project root as middleware.js or middleware.ts.
Explain how you can modify an incoming request URL in Next.js using middleware.
Think about how middleware can change the path without redirecting.
You got /4 concepts.
Describe the difference between rewriting and redirecting a request in Next.js middleware.
Consider what the user sees in the browser address bar.
You got /4 concepts.