Can't enable CORS on my website

Hello,

I want to block requests from other domains, and allow only my domain.
I tried to to it by this code in PHP:

header("Access-Control-Allow-Origin: http://my_username_domain.000webhostapp.com");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");

but then when I try to send request to any php file on ther server, from localhost (for example)
the code does not block the request.

why?
thanks.

Hello. Not sure if this causes the issue, but OPTIONS method is not supported on free plans.

This topic was automatically closed after 47 hours. New replies are no longer allowed.