Testei seu código e não aparece aquele erro.
Será que estamos falando da mesma coisa?
Preparei um repositório no GitHub. Segue as instruções do README e me diz se tiver algum problema, tá bom?
Testei, me retorna isso no console (No localhost:8001):
localhost/:1 Access to fetch at 'http://localhost:8003/destino.php' from origin 'http://localhost:8001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. (índice):12
Uncaught (in promise) TypeError: Failed to fetch at doRequest ((índice):12:9) at (índice):21:7 doRequest @ (índice):12 (anônimo) @ (índice):21 Promise.then (assíncrono) doRequest @ (índice):18 (anônimo) @ (índice):21
(índice):18 Warning: file_get_contents(http://localhost:8003/destino.php): Failed to open stream: Cannot assign requested address in /var/www/html/proxy.php on line 28 Warning: Undefined variable $http_response_header in /var/www/html/proxy.php on line 29 Warning: foreach() argument must be of type array|object, null given in /var/www/html/proxy.php on line 31
Está usando qual navegador?