title: Nodejs redirect return NULL
body: <p>I am building a WordPress woocommerce payment plugin, and an API inside a Nodejs backend server to connect with.</p>
  
  <p>I am using curl to call API ('<a href="https://test.com/test" rel="nofollow noreferrer">https://test.com/test</a>') as normal:</p>
  
  <pre><code>$curl = curl_init($url);
      curl_setopt_array($curl, array(
          CURLOPT_POST =&gt; true,
          CURLOPT_RETURNTRANSFER =&gt; true,
          CURLOPT_HEADER =&gt; false,
          CURLOPT_HTTPHEADER =&gt; $header,
          CURLOPT_POSTFIELDS =&gt; json_encode($body)
      ));
  
      $result = curl_exec($curl);
      curl_close($curl);
  
      $response = json_decode($result);
  </code></pre>
  
  <p>And then in my API, I have to receive and check POST paramemters, and then redirect to another router ('<a href="https://test.com/render" rel="nofollow noreferrer">https://test.com/render</a>) to render an ejs view page.
  I tried to use</p>
  
  <pre><code>res.redirect(307, 'https://test.com/test')
  </code></pre>
  
  <p>or</p>
  
  <pre><code>res.writeHead(307, { 'Location': 'https://test.com/test' });
  res.end();
  </code></pre>
  
  <p>or render the page directly</p>
  
  <p><code>res.render('index', { merchantUser: UserID });</code></p>
  
  <p>or even</p>
  
  <pre><code>window.location.href = 'https://test.com/test'
  </code></pre>
  
  <p>But the first three returned NULL directly, and the last one return 'window not defined'. And none of them reaches the redirect router ('<a href="https://test.com/render" rel="nofollow noreferrer">https://test.com/render</a>).</p>
  
  <p>Thats all I can find online, could someone help me or give me some advices? Thanks a lot.</p>