Skip to content

CORS Error when using NodeJS Connect V2 API for OAuth2 Access #203

@minhazfm

Description

@minhazfm

Following the guide posted on Square's Developer documentation. I can run the Node OAuth 2 sample from here: (https://github.com/square/connect-api-examples/tree/master/connect-examples/oauth/node) just fine locally with the Sandbox. But when I try to run a similar setup in a local React app, the obtainToken method from the square-connect Node library throws the following error:

Refused to set unsafe header "User-Agent"

Access to XMLHttpRequest at 'https://connect.squareupsandbox.com/oauth2/token' from origin 'http://localhost:3000' 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.

client.js:772 POST https://connect.squareupsandbox.com/oauth2/token net::ERR_FAILED

Not sure how to overcome the CORS policy here. Could I get some assistance please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions