Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-Origin Request Blocked: Unable to fetch from server in project. #1

Closed
dhrudevalia opened this issue Apr 16, 2022 · 0 comments · Fixed by #2
Closed

Cross-Origin Request Blocked: Unable to fetch from server in project. #1

dhrudevalia opened this issue Apr 16, 2022 · 0 comments · Fixed by #2

Comments

@dhrudevalia
Copy link

I wanted to have a little play around and perhaps build a funny front end (React + TS), and just doing some preliminary api checks.
And am receiving this error.

If i'm not mistaken i believe on the backend side you need to enable access-control-allow-origin: * to allow users to fetch results in their own apps.

Error below:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://owen-wilson-wow-api.herokuapp.com/wows/movies. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘https://owen-wilson-wow-api.herokuapp.com’).

Please correct me if i'm wrong.

This is the code i'm running.

const getWow = (): Promise<Response> => {
  return fetch('https://owen-wilson-wow-api.herokuapp.com/wows/movies')
}

const fetchWow = () => {
  getWow().then((w) => {
    console.log(w.json)
  })}

Attached to a button onclick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant