title: How to configure proxy in Vite?
body: <p>I was trying to follow the docs and created <code>vite.config.js</code> like this:</p>
  <pre><code>const config = {
    outDir: '../wwwroot/',
    proxy: {
      // string shorthand
      '/foo': 'http://localhost:4567',
      // with options
      '/api': {
        target: 'http://jsonplaceholder.typicode.com',
        changeOrigin: true,
        rewrite: path =&gt; path.replace(/^\/api/, '')
      }
    }
  };
  
  export default config;
  </code></pre>
  <p>And tried to test it with following calls:</p>
  <pre><code>fetch('/foo');
  fetch('/api/test/get');
  </code></pre>
  <p>I was expecting to have actual requests as <code>http://localhost:4567/foo</code> and <code>http://jsonplaceholder.typicode.com/test/get</code>
  But both of them had my dev server as an origin like this: <code>http://localhost:3000/foo</code> and <code>http://localhost:3000/api/test/get</code></p>
  <p>Did I misunderstand it? How proxies should work?</p>
  <p>I also created an <a href="https://github.com/vitejs/vite/issues/1014" rel="noreferrer">issue</a> in the Vite repo but it was closed and I did not understand the closing comment.</p>