Implement a more flexible CORS origin detection