title: NextJs Authentication with Next-Auth against DRF
body: <p>I have an exiting Django project that I am trying to move from templates to NextJs frontend. I came across Next-Auth-js which seems to be nice in Next Auth.</p>
  <p>However, the doc seems to focus more with JS related Backend Auth. Following this <a href="https://github.com/vercel/next.js/blob/canary/examples/with-next-auth" rel="nofollow noreferrer">example</a> I have sent the NEXTAUTH_URL environment variable to my DRF Endpoint localhost:8002. While the frontend runs on localhost:3000. While my _app.js looks like this:</p>
  <pre><code>&lt;Provider options={{site: process.env.NEXTAUTH_URL,}} session={pageProps.session}  &gt;
    &lt;Component {...pageProps} /&gt;
  &lt;/Provider&gt;
  </code></pre>
  <p>Using the <a href="https://github.com/vercel/next.js/blob/canary/examples/with-next-auth/components/nav.js" rel="nofollow noreferrer">Nav.js</a> for a test, I changed the signin/out href to point to my Django endpoints but it seems next-auth-js ignores this and places a session fetch to my frontend <code>http://localhost:3000/api/auth/session</code> instead of the the <code>http://localhost:8002/api/auth/session</code>.</p>
  <p>I will appreciate any assistance on how I can correctly/securely implement this authentication using Django Rest Framework (DRF)</p>