tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
13 lines • 898 B
text/typescript
/**
* Redirects requests from invalid domains to a specified base URL or calls a callback function.
* This middleware checks the 'x-forwarded-host' header of incoming requests and compares it to a list of valid domains.
* If the domain is invalid, it either redirects to the base URL or calls a provided callback.
*
* @param {string[]} [domains=['localhost:5000', 'example.com']] - A list of valid domains that the request must come from.
* @param {string} [baseurl='https://example.com/'] - The URL to redirect invalid requests to.
* @param {Function} [callback] - An optional callback function that is called when an invalid domain is detected.
*
* @returns {Function} A middleware function for use in an Express.js application.
*/
export default function domainRedirect(domains?: string[], baseurl?: string, callback?: Function): Function;
//# sourceMappingURL=domainRedirect.d.mts.map