Search code snippets, questions, articles...

Allow CORS in PHP

    header("Access-Control-Allow-Origin: *");
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

If you are getting CORS error in your console while making an HTTP request to a PHP file, you can add above code in your file. This will allow all domains to make an HTTP request with your domain.

Was this helpful?