title: How to run django-rest-framework and react on the same domain?
body: <p>Working on a website that uses <code>django-rest-framework</code> for the backend and <code>reactjs</code> + <code>redux</code> for the frontend.</p>
  
  <p>Now my backend server is on a <code>vagrant</code> ubuntu machine on URL and port <code>http://localhost:8080</code>. Frontend using <code>react</code> + <code>redux</code> + <code>webpack(port 80)</code> + <code>cross-fetch</code> for API request/response, server is on <code>http://localhost</code>. </p>
  
  <p>Facing two errors, when requesting an API using <code>cross-fetch</code> on <code>redux</code> for fetching data.</p>
  
  <p>first error:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>Is it because of the different ports?</p>
  
  <p>second error: </p>
  
  <pre><code>Uncaught (in promise) TypeError: Network request failed
  at XMLHttpRequest.xhr.onerror (browser-ponyfill.js:445)
  </code></pre>
  
  <p>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 <code>nodejs</code> and <code>django</code> can not use the same port. When running one of them the other one cannot run on that port.</p>