404 response to the OPTIONS preflight request

Hi, I’m trying to set up a custom request handler in the worker function to handle the basic authorization.
At first, I implemented an OPTIONS request handler to handle the cross-domain requests correctly and that part worked.
But when I started implementing a basic authorization that uses a custom request header, I started getting a 404 error to the OPTIONS preflight request. That is also an issue for ANY request header (Content-Type, for example). So, basically, there is an issue when I add any request header, then OPTIONS preflight requests fail with 404.