Access To XMLHttpRequest At 'http://localhost:8081/api/v1/plans' From Origin 'http://localhost:4200' Has Been Blocked By CORS Policy: Request Header Field Content-type Is Not Allowed By Access-Control-Allow-Headers In Preflight Response. Code Example


Example: Access to XMLHttpRequest at 'http://localhost/MySQL_pracs/InsertUser.php' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

//Access to XMLHttpRequest at 'http://localhost/[api path].php' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.  //The error is simply saying that "Content-Type" is missing from "Access-Control-Allow-Headers".  //Therefore we need to add "Content-Type" to "Access-Control-Allow-Headers".  <?php  header('Access-Control-Allow-Headers: Content-Type'); ----- ?>

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable