Working on a website that uses django-rest-framework for the backend and reactjs + redux for the frontend.
Now my backend server is on a vagrant ubuntu machine on URL and port http://localhost:8080. Frontend using react + redux + webpack(port 80) + cross-fetch for API request/response, server is on http://localhost.
Facing two errors, when requesting an API using cross-fetch on redux for fetching data.
first error:
Failed to load http://localhost/courses-api/all-courses/:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8000' is therefore not allowed access.
Is it because of the different ports?
second error:
Uncaught (in promise) TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (browser-ponyfill.js:445)
Can not find out a way to solve the problem. Will using the same port for both solve my problem?. Found on the web for solving the first error, but can't do that as nodejs and django can not use the same port. When running one of them the other one cannot run on that port.