I get the following error when using Stripe in React. I'm assuming my server is set-up right. So how do I resolve an Access-Contorl-Allow-Origin error?
> Access to fetch at 'http://localhost:9000/charge' from origin
> 'http://localhost:3000' has been blocked by CORS policy: No
> 'Access-Control-Allow-Origin' header is present on the requested
> resource. If an opaque response serves your needs, set the request's
> mode to 'no-cors' to fetch the resource with CORS disabled.
async submit(ev) {
let {token} = await this.props.stripe.createToken({name: "Name"});
let response = await fetch("http://localhost:9000/charge", {
method: "POST",
headers: {"Content-Type": "text/plain"},
mode: "no-cors",
body: token.id
});
if (response.ok) this.setState({complete: true});
}
This is the tutorial I'm following... https://stripe.com/docs/recipes/elements-react
As a follow up, the error was resolved using one of their test credit cards... https://stripe.com/docs/testing