title: Proxy to backend with default Next.js dev server
body: <p>Before, when I made apps with create-react-app, I would have a <code>setupProxy.js</code> file that would route API requests similar to this</p>
  
  <pre><code>const proxy = require('http-proxy-middleware');
  module.exports = function(app) {
      app.use('/api',
          proxy({
              target: 'http://localhost:8000',
              changeOrigin: true,
          })
      );
  };
  </code></pre>
  
  <p>But that doesn't seem to work with next.js.  When I do the same thing, I get various errors.  </p>
  
  <p>Googling a solution, a lot say to use a custom server of some kind.  But how would I accomplish a proxy like above using the default nextjs dev server? (Equivalent of <code>npm run dev</code> when <code>dev</code> in my package.json is <code>next dev</code>.</p>