title: How do I forward a cookie using fetch in getServerSideProps?
body: <p>I'm using Nextjs for my app. On a page, I would like to fetch data from an authenticated API endpoint ('/api/profile').</p>
  
  <p>I have tried the following, with no success:</p>
  
  <pre><code>export async function getServerSideProps(ctx) {
    const { req, res } = ctx
    const cookies = cookie.parse(req.headers.cookie ?? '')
    const mycookie = cookies[MY_COOKIE] // mycookie exists and is set correctly
  
    if (mycookie) {
      const response = await fetch(process.env.SERVER_HOST+'/api/profile', {
        credentials: 'same-origin' // I tried with and without this, also tried "include" instead
      })
  
    ...
  
  </code></pre>
  
  <p>I have 2 questions:</p>
  
  <ul>
  <li>Is there a way to avoid having to enter the absolute URL? (I was hoping to simply use '/api/profile', since it's an "internal" api)</li>
  <li>How do I make sure the cookie required to fetch data from /api/profile is forwarded through <code>fetch</code>?</li>
  </ul>
  
  <p>N.B: My cookie is <code>httpOnly</code>.</p>