Auth0 Home Blog Docs

Problem with cors in custom react login


#1

I am a noob in Auth0, and for reasons of my application, I need to create a custom login.

  • When I use the postman, I can connect to the service
    https: // {{MY_DOMAIN}}.auth0.com/oauth/token
    passing it in the body of the petition
    {
    “grant_type”: “password”,
    “username”: “”,
    “password”: “”,
    “client_id”: “”,
    “client_secret”: “”
    }
    and everything is good, but when I try to connect with " fetch" to this URL (https://{{MY_DOMAIN}}.auth0.com/oauth/token). The auth0 service respond me
    {
    type: “cors”,
    url: “https://{{MI_DOMAIN}}.auth0.com/oauth/token”,
    redirected: false,
    status: 401,
    ok: false,
    …}

Please, what I need make to resolve this problem?


#2

@r41d0n, I think this is a simple configuration problem. When you make requests with Postman those requests are not subject to Cross Origin Resource Sharing. When you make these calls from a web browser you are. So auth0, in this case is telling the browser what the allowed origins are. Each client can be configured to allow origins via its settings/configuration.

I believe you simply need to configure the origin of the request. That is what domain is being used to host your application that is making the call.