title: Nextjs: 405 when form submit POST
body: <p>Following this <a href="https://nextjs.org/blog/forms" rel="nofollow noreferrer">tutorial</a>, I'm trying to submit a form in Nextjs but get a 405 error when trying to POST to my api route. I've tried using both axios and the fetch api. This seems like it should be simple to do but I'm not sure where I'm going wrong. Anything obvious I'm missing? Thanks!</p>
  <p><strong>/survey/create</strong></p>
  <pre><code>const handleSubmit = async (event) =&gt; {
      event.preventDefault();
  
      const testData = {
        title: surveyTitle,
      };
  
      const res = await fetch(&quot;/api/survey&quot;, {
        method: &quot;POST&quot;,
        body: JSON.stringify({
          dataName: testData,
        }),
        headers: {
          &quot;Content-Type&quot;: &quot;application/json&quot;,
        },
      });
    };
  
  </code></pre>
  <p><strong>/api/survey</strong></p>
  <pre><code>export default function handler(req, res) {
    console.log(req.body);
    res.status(200).json(JSON.stringify({ name: 'Success' }))
  }
  </code></pre>