Recall & Review
beginner
What is response modification in Next.js?
Response modification means changing the server's reply before it reaches the user. In Next.js, you can adjust headers, status codes, or body content in server actions or API routes.
Click to reveal answer
beginner
How do you set a custom header in a Next.js API route?
Use the Response object’s
setHeader method. For example, res.setHeader('Cache-Control', 'max-age=3600') adds a cache control header.Click to reveal answer
beginner
Why would you modify the response status code in Next.js?
Changing the status code helps tell the browser or client what happened. For example,
res.status(404) means the page was not found, so the client can handle it properly.Click to reveal answer
intermediate
What is a common use case for modifying the response body in Next.js server actions?
You might add extra data or format the response before sending it. For example, wrapping data in an object with a message or filtering sensitive info.
Click to reveal answer
intermediate
How does Next.js 14+ support response modification in the App Router?
Next.js 14+ uses server actions and the new Response API, letting you create and return custom Response objects with headers, status, and body directly from route handlers.
Click to reveal answer
In Next.js API routes, which method sets a response header?
✗ Incorrect
Use
res.setHeader() to add or change headers in the response.What status code should you use to indicate a resource was not found?
✗ Incorrect
Status code 404 means 'Not Found', telling the client the resource doesn't exist.
Which Next.js feature allows returning custom Response objects?
✗ Incorrect
Server Actions in Next.js 14+ let you create and return custom Response objects.
Why modify the response body before sending it?
✗ Incorrect
Modifying the body lets you customize the data the client receives.
Which of these is NOT a reason to modify response headers?
✗ Incorrect
Response headers cannot change the HTTP request method.
Explain how you would modify a response in a Next.js API route to add a custom header and set a 200 status code.
Think about how to use res.setHeader and res.status in your handler.
You got /4 concepts.
Describe the benefits of modifying the response body in Next.js server actions and give an example scenario.
Consider why you might want to change what the client receives.
You got /4 concepts.