first to configure your web server to allow origins and Headers code example
Example 1: 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.
<?php
header('Access-Control-Allow-Headers: Content-Type');
-----
?>
Example 2: what is cors
“CORS” stands for Cross-Origin Resource Sharing.
It allows you to make requests from one website to another website
in the browser, which is normally prohibited by another browser policy
called the Same-Origin Policy (SOP).