Salesforce-B2C-Commerce-Cloud-Developer Practice Test

Salesforce Spring 25 Release
202 Questions

A controller route in the SFRA base looks as follows:



In order to extend this route using prepared ( ), what should the developer consider?

A. Specifyany middleware functions needed for the new functionality.

B. Specify any middleware functions needed for the new functionality using only those called by thebase route.

C. Remove next ( ); on the new route so only the route's middleware functions execute.

A.   Specifyany middleware functions needed for the new functionality.

Explanation:

The code shown is a controller route definition in SFRA using server.get():
server.get('Show', consentTracking.consent, cache.applyDefaultCache, function (req, res, next) { // base code ...
next();
}, pageMetaData.computedPageMetaData);

This route uses middleware functions like consentTracking.consent, cache.applyDefaultCache, and pageMetaData.computedPageMetaData.

🔄 When Extending a Route Using server.append() or server.prepend():
You can add custom behavior before or after the base implementation.
Middleware like consentTracking.consent and cache.applyDefaultCache is not automatically inherited — you must explicitly specify any middleware needed for your extension.
The next() call inside the base route enables middleware chaining, so extensions defined with .append() will execute after that.

🧠 What You Must Consider:
When using .append('Show', ...), your custom route function will not inherit any middleware used in the base route. You must explicitly specify any that are needed for your logic to function correctly.
So:
✅ You can add any middleware functions needed — not just those used in the base route.
You are free to add new ones depending on your custom logic.

Why Other Options Are Incorrect:
B. Only use middleware from the base route
❌ Too restrictive. You can use any middleware your logic requires — not just the ones from the base.
C. Remove next()
❌ Removing next() from the base would prevent .append() logic from running. It must be retained to allow proper chaining.

Salesforce-B2C-Commerce-Cloud-Developer Practice-Test - Home Previous
Page 29 out of 202 Pages