fixed bug with cors when error happend before cors()