Recall & Review
beginner
What is middleware in NestJS?
Middleware in NestJS is a function that runs before the route handler. It can modify the request or response, or end the request-response cycle.
Click to reveal answer
beginner
What does the CORS middleware do?
CORS middleware allows or restricts cross-origin requests from browsers, helping control which websites can access your API.
Click to reveal answer
beginner
What is Helmet middleware used for in NestJS?
Helmet helps secure your app by setting various HTTP headers that protect against common web vulnerabilities.
Click to reveal answer
beginner
How do you enable CORS in a NestJS application?
You enable CORS by calling app.enableCors() in the main.ts file before starting the app.
Click to reveal answer
beginner
How do you apply Helmet middleware in NestJS?
You apply Helmet by importing it and calling app.use(helmet()) in the main.ts file before app.listen().
Click to reveal answer
What is the main purpose of CORS middleware?
✗ Incorrect
CORS middleware controls which external websites can access your API by managing cross-origin requests.
Which HTTP headers does Helmet help set?
✗ Incorrect
Helmet sets security headers such as Content-Security-Policy and X-Frame-Options to protect your app.
Where do you typically enable CORS in a NestJS app?
✗ Incorrect
CORS is enabled in main.ts before starting the app to apply it globally.
How do you add Helmet middleware to a NestJS app?
✗ Incorrect
Helmet middleware is added by calling app.use(helmet()) in main.ts before app.listen().
Which of these is NOT a benefit of using Helmet?
✗ Incorrect
Enabling cross-origin requests is handled by CORS, not Helmet.
Explain how to add and configure CORS middleware in a NestJS application.
Think about where the app starts and how browsers restrict requests.
You got /3 concepts.
Describe what Helmet middleware does and why it is important for NestJS apps.
Consider how websites protect themselves from hackers using headers.
You got /3 concepts.