Access to XMLHttpRequest at 'https://**' from origin 'https://**' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 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: Access to XMLHttpRequest has been blocked by CORS policy React
const cors = require('cors');
const corsOptions ={
origin:'http://localhost:3000',
credentials:true,
optionSuccessStatus:200
}
app.use(cors(corsOptions));