Skip to main content


expressly's router can be initialized with an optional configuration object:

const router = new Router({
parseCookie: true,
auto405: true,
extractRequestParameters: true,
autoContentType: true,
autoCorsPreflight: {trustedOrigins: []}



Default 🟢 true

When set to true, enables parsing of the Cookie request header and exposes req.cookies.


Default 🟢 true

When set to true, expressly will respond with HTTP 405 Method Not Allowed and automatically set the Allow header if it cannot match the client request method on a matched path.

In the example below, a POST request to the /users path will result in a HTTP 405 response.

const router = new Router({ auto405: true });
router.get("/users", (req, res) => { ... });

Setting auto405: false above will cause expressly to respond with HTTP 404.


Default 🟢 true

When set to true, exposes req.params, an object containing properties mapped to any named route "parameters".


Default 🔴 false 🔥 experimental

When set to true, res.send will try to infer the Content-Type header from the data it is passed, if the header is not set.


Configures options for Cross-origin resource sharing automatically.

  • trustedOrigins: An array of origins from which to automatically accept CORS preflight requests. Using the literal value * will accept all origins but will only work if the request is being sent without credentials. See the MDN documentation on Access-Control-Allow-Origin for more.