2

On my local development (vagrant, apache, ubuntu) I have no problem setting Access-Control-Allow-Headers using PHP headers function.

But in production, Litespeed on CENTOS 6.7. The php header function is ignored and the Access-Control-Allow-Headers are always set to

X-Accept-Charset,X-Accept,Content-Type.

But I can set them in the htaccess file.

Header set Access-Control-Allow-Headers Origin, Content-Type, Accept, Authorization, X-Requested-With

The PHP headers function does work in production for

Access-Control-Allow-Origin "*"

This seems like a server configuration issue but I can't figure out where it is being set.

Why would litespeed ignore PHP header function for some headers and not others?

Patrick_Finucane
  • 725
  • 1
  • 7
  • 24

1 Answers1

0

The problem was spaces in the headers...

It seems like both apache and litespeed treat php header function and htaccess "header set blah...blah" Differently.

So you can set

X-Accept-Charset,X-Accept,Content-Type,Origin, 

but not

X-Accept-Charset, X-Accept, Content-Type, Origin

In different places. Spaces work in apache php header function but not Litespeed, and spaces work in litespeed thaccess "header set" but not in apache.

Patrick_Finucane
  • 725
  • 1
  • 7
  • 24