CORS issue caused by redirecting the user in PHP

I get this error, when I redirect the user to a different domain with php header command.

Error message:
Failed to load xxxxx.com Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://XXXX.local’ is therefore not allowed access.

This is the php redirect command:
header(‘Location: https://XXXXXX.com/’);
die();

I found a similar question, and suggested to use the header set command below to avoid the CORS issue. But, this did not work for me. Can anyone suggest what I am doing wrong?

Change I made:
Header set Access-Control-Allow-Origin “*”
This is the file I modified:
XXXX\Local Sites\apform\conf\apache\sites-enabled\000-default.conf

My environment:
Local by flywheel ver 2.4.3
Web server Apache
PHP version 7.0.3
Wordpress version 4.9.8

Thank you