cors function

FECallBackWithNext cors([
  1. CorsOptions? options
])

Implementation

FECallBackWithNext cors([CorsOptions? options]) {
  options ??= CorsOptions();
  return (Req req, Res res, Function next) {
    if (req.method == 'OPTIONS') {
      // Handle CORS preflight request
      setCorsHeaders(res);
      res.setStatusCode(HttpStatus.ok);
      res.close();
      return;
    } else {
      next();
    }
  };
}