Origin 'http://localhost:4200' has been blocked by CORS policy

Even after allowing origin, why still receiving CORS prefight error?


Hi @Rajan_Braiya,

Are you using bearer authentication as outlined here? https://www.mongodb.com/docs/atlas/api/data-api/#authenticate-web-browser-requests

Hi @Kiro_Morkos, thank you for your reply. I understand that we cannot use email/password for the web application.

Even our requirement is to use a custom authentication function, but I am encountering an error: “Http failure response.” hence was trying with Email/Password but I would highly appreciate your assistance in resolving all of my issues. For more details, you can find additional information on the issue at No authentication methods were specified.

You should be able to use any of your authentication providers to get an access token (see https://www.mongodb.com/docs/atlas/app-services/users/sessions/#get-a-user-session-access-token). Once you have an access token, you can use it to authenticate your Data API request via Bearer auth from the browser.