Stric provides the CORS class to parse and check request origin.
import { Router } from'@stricjs/router';import { CORS } from'@stricjs/utils';constcors=newCORS();// Parsed headers without 'Access-Control-Allow-Origin' // if this header value is not '*'cors.headers;// Check if an origin exists in the allowed origins list// This function returns the origin as 'Access-Control-Allow-Origin' if matchescors.check('example.com');
Here's more options that you can use to specify the CORS headers to return.