Dear all
I set headers of responses and I got an internal server error , when some headers are disable there is no error
I defined a function to set response header in php on XAMPP as below
public static function setHeaders($status_code)
{
header("Access-Control-Allow-Origin : *");
header("Content-Type:application/json; charset:UTF-8");
header("Access-Control-Allow-Methods :PUT, GET, POST,DELETE");
header("Access-Control-Max-Age :3600");
header ("Access-Control-Allow-Headers : Content-Type, X-requested-with,Authorization");
header("HTTP/1.1 $status_code) " . self::statusTexts[$status_code]);
}
when I want to get responses an error occurs. like this
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.1.6 Server at localhost Port 80
but when these following header functions are disable (they are commented below);
// header("Access-Control-Allow-Origin : *");
header("Content-Type:application/json; charset:UTF-8");
// header("Access-Control-Allow-Methods :PUT, GET, POST,DELETE");
// header("Access-Control-Max-Age :3600");
// header ("Access-Control-Allow-Headers : Content-Type, x-requested
header("HTTP/1.1 $status_code) " . self::statusTexts[$status_code]);
,there is not any error and response is OK.
why ?Is there any suggestion?
I will be very grateful for your help, friends.