QuizzesMiddleware — Concept Check
intermediate
nextjs

Middleware — Concept Check

Questions on Middleware. Code that runs before every matched request, on the edge, with no database and a tight time budget. Right for redirects and coarse gates; wrong as your authorisation layer.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Middleware — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer notices that their Next.js application is slow due to middleware. What should they check first?

    • AEnsure the middleware is not performing heavy computations
    • BAdd more matchers to the middleware configuration
    • CLog every request in the middleware
    • DUse middleware for authorisation checks
  2. 2.In a Next.js application, middleware is used to redirect unauthenticated users from '/dashboard'. What is a potential issue with this approach?

    • AMiddleware can access the database for session checks
    • BMiddleware cannot perform redirects
    • CMiddleware can be bypassed with crafted headers
    • DMiddleware is the best place for authorisation
  3. 3.A developer wants to use middleware to verify JWT tokens. What should they keep in mind?

    • AMiddleware should handle token verification as it is secure
    • BMiddleware can access the database for token verification
    • CMiddleware can use Node APIs for token processing
    • DMiddleware can verify JWT signatures but not check revocation
  4. 4.What is the primary role of middleware in a Next.js application?

    • ATo handle all authorisation checks
    • BTo redirect users and attach headers
    • CTo log detailed request information
    • DTo perform complex business logic
  5. 5.A team uses middleware to attach request IDs to responses. What is a potential downside of this approach?

    • AIt adds unnecessary complexity to the application
    • BIt increases the size of the response headers
    • CIt can significantly slow down the application
    • DIt might expose sensitive information
  6. 6.Why is middleware not suitable as an authorisation layer in Next.js applications?

    • AIt can be bypassed with crafted headers
    • BIt runs after the data is accessed
    • CIt does not support JWT verification
    • DIt cannot redirect unauthenticated users
  7. 7.A developer configures middleware to run on all routes except static assets. What might they forget to consider?

    • AMiddleware runs on prefetches, potentially causing unnecessary redirects
    • BMiddleware should run on all routes, including static assets
    • CMiddleware can access static assets directly
    • DMiddleware should be used for all authorisation checks
  8. 8.What constraint does the edge runtime impose on middleware in Next.js?

    • AMiddleware can use Node APIs for complex operations
    • BMiddleware must complete operations in a few milliseconds
    • CMiddleware can perform heavy computations without performance impact
    • DMiddleware can access the database for session data