Auth0 Home Blog Docs

Cors error sending password reset post request

#1

Authentication already works in my app so i can login/logout. I am trying to add reset password functionality to my app and have problem triggering reset password email.

I am following instructions from https://auth0.com/docs/connections/database/password-change.
I am trying to make request to the Authentication API from browser.
I added url(localhost) to Allowed Web Origins but still get cors error.

public static passwordReset(email: string): Promise<any> {
        let options: any = {
            method: 'POST',
            url: 'https://myapp.auth0.com/dbconnections/change_password',
            headers: { 'content-type': 'application/json' },
            body: {
                client_id: 'myclientId',
                email: '',
                connection: 'Username-Password-Authentication'
            },
            json: true
        };
        return fetch(
            'https://myapp.auth0.com/dbconnections/change_password',
            options
        );
    }

can You help me with this?

#3

Hi there @tomasz.szyszko, It’s interesting you are running into this issue after adding the route to the Allowed Web Origins. When you get a chance can you send me in a direct message your tenant name so I can take a closer look at what may be going on? Thanks in advance!

#4

Hi,
I found solution already,
body inside options needs to be JSON.stringified for request to be correct.
Error text was misleading but I managed to solve it.
Thank You, This topic can be closed

#5

I’m glad it all worked out! Please let us know in the future if we can be of assistance, thanks!

closed #6

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.