title: Nextjs api "pages/api" doesn't work on vercel server
body: <p>Hello guys may you help me?</p>
  <p>I'm trying to configure my fake API to create some personal projects but in my case, the method using the <strong>/pages/api</strong> folder only works for me in localhost when I deploy to the server on Vercel the project can't find my endpoints.</p>
  <p>In my case I'm using the src/ folder method to develop my app and I don't know if this structure can cause problems with api folder.</p>
  <p>One thing that I tried and worked is deploying to vercel using the api folder at the root of the application (out of /src folder) but the api stop working on localhost.</p>
  <p>This structure works on localhost but doesn't work on server:</p>
  <pre><code>├───public/
  ├───src/
      ├───api/
      ├───pages/
      ...
  next.config.js
  package.json
  </code></pre>
  <p>This structure works on server but doesn't work on localhost:</p>
  <pre><code>├───api/
  ├───public/
  ├───src/
      ├───pages/
      ...
  next.config.js
  package.json
  </code></pre>
  <p>This is the method that I'm using to get data:</p>
  <p>AXIOS API:</p>
  <pre class="lang-js prettyprint-override"><code>import axios from 'axios'
  
  const api = axios.create({
    baseURL: '/api/'
  })
  
  export default api
  </code></pre>
  <p>SWR HOOK:</p>
  <pre class="lang-js prettyprint-override"><code>import api from 'src/services/api'
  import useSWR from 'swr'
  
  function SwrFetchHook&lt;Data = any, Error = any&gt;(url: string) {
    const { data, error } = useSWR&lt;Data, Error&gt;(url, async url =&gt; {
      const response = await api.get(url)
      return response.data
    })
  
    return { data, error }
  }
  
  export default SwrFetchHook
  </code></pre>
  <p>SWR callback:</p>
  <pre class="lang-js prettyprint-override"><code>const { data } = SwrFetchHook&lt;INavItem[]&gt;('categories')
  
  </code></pre>
  <p>I hope that I could explain, my question here is how is the best way to work with this feature because the /src folder is common to use with nextjs but I don't know if this is the real problem with the api folder.</p>
  <p>Thanks!</p>