Much better implementation of the CORS filter