php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Cli-server mode cannot send Access-Control-Allow-Origin header

Open huye opened this issue 4 years ago • 3 comments

Description

The following code:

<?php

header('Access-Control-Allow-Origin: *');
header("Access-Control-Expose-Headers: Content-Disposition");
header('Access-Control-Origin: xxx.hoo.com');
die('header test');

Resulted in this output:

I used the curl -I command to test, but did not output the first header.

But I expected this output instead:

PHP Version

PHP 7.4.3

Operating System

kde neon / Ubuntu 20.04.3 LTS

huye avatar Dec 15 '21 03:12 huye

By the way, the same code is normal in nginx + php-fpm mode.

huye avatar Dec 15 '21 04:12 huye

Works for me in PHP 7.4.26.

ubuntu:~/php$ cat gh7777.php
<?php

header('Access-Control-Allow-Origin: *');
header("Access-Control-Expose-Headers: Content-Disposition");
header('Access-Control-Origin: xxx.hoo.com');
die('header test');

ubuntu:~/php$ jobs
[1]+  Running                 php-7.4.26/bin/php -S localhost:8000 -t . 2> /dev/null &
ubuntu:~/php$ curl -I http://localhost:8000/gh7777.php
HTTP/1.1 200 OK
Host: localhost:8000
Date: Wed, 15 Dec 2021 04:30:17 GMT
Connection: close
X-Powered-By: PHP/7.4.26
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Disposition
Access-Control-Origin: xxx.hoo.com
Content-type: text/html; charset=UTF-8

Your 7.4.3 is old. Try again with a more recent version.

If not then include the php CLI command you used and, as the bug template said, the actual outputs of what you saw running curl.

damianwadley avatar Dec 15 '21 04:12 damianwadley

No feedback was provided. The issue is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so. Thank you.

github-actions[bot] avatar Dec 30 '21 00:12 github-actions[bot]