@Igor, did you ever get this resolved? I am facing this exact issue and struggling to get passed it.
I have no answer yet and even using your code to remove the CSP for localhost is not working.