Access to XMLHttpRequest at 'http://localhost:8800/api/auth/register' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
To resolve this issue, you need to configure your backend server to include the appropriate CORS headers in its responses. You'll need to set the Access-Control-Allow-Origin header to allow requests from the origin where your frontend application is hosted (localhost:4200 in your case).
If you're using Node.js with Express, you can use the cors middleware to enable CORS in your server application.
`
const express = require('express');
const cors = require('cors');
const app = express();
// Enable CORS for all origins
app.use(cors());
// Other middleware and routes...
app.listen(8800, () => {
console.log('Server is running on port 8800');
});`
This code sets up a basic Express server and uses the cors middleware to enable CORS for all origins. Make sure to adjust the options passed to cors() if you want to restrict access to specific origins, methods, or headers.
i hope After making these changes and restarting your server, requests from localhost:4200 to localhost:8800 should no longer be blocked by CORS policy.
Best Regard
Danish Hafeez | QA Assistant
ICTInnovations