title: Is it possible to run webpack dev server and backend server on same hostname and port to avoid CORS?
body: <p>I am running a backend Laravel API and a frontend Vue.js application.</p>
  
  <p>Option #1 would be to set those two up as follows:</p>
  
  <pre><code>api.example.com =&gt; serving the API
  app.example.com =&gt; serving the frontend appplication
  </code></pre>
  
  <p>However this gets you in all the trouble with CORS, OPTIONS preflight etc.</p>
  
  <p>So in order to avoid that, I am planning on setting it up like this:</p>
  
  <pre><code>app.example.com/api =&gt; serving the API
  app.example.com =&gt; serving the frontend appplication
  </code></pre>
  
  <p>So no more CORS problems, but since I am using Webpack I am running into issues in local development. Webpack dev server is serving the frontend at:</p>
  
  <pre><code>app.example.com:8080
  </code></pre>
  
  <p>So again, I am running into CORS when trying to access the API on port 80 :-(</p>
  
  <p>Help! How can I set this up, so I don't have to deal with CORS yet being able to make use of the Webpack dev server and the Laravel (Homestead) API backend?</p>
  
  <p>I assume it's not possible to serve both Homestead as well as Webpack from the same hostname and port. But is there any set-up that avoids CORS?</p>