title: ReactJS and Express with Axios returning 404 Error message
body: <p>I have a Node/Express server running on the back end, and a react front end, and am trying to make the simplest API - yet no matter what I do I seem to be getting an error 404 in the post request. I've tried adding a proxy into package.json, removing the proxy and including the port in the address i..e <a href="http://localhost:5000/createaccount" rel="nofollow noreferrer">http://localhost:5000/createaccount</a>, including the proxy to <a href="http://localhost:5000" rel="nofollow noreferrer">http://localhost:5000</a> and just using '/createaccount' in the post request. I've tried various things with CORS and headers, nothing seems to be working.</p>
  
  <p>When I go to <a href="http://localhost:5000/createaccount" rel="nofollow noreferrer">http://localhost:5000/createaccount</a> in my browser separately, it does successfully log "hello world" so I know the server running. I'm also aware for now nothing is actually being done with the sent data, just trying to actually establish a connection for now! I've also tried uncommenting/commenting out most things within the fetch request to no avail.</p>
  
  <p>Server.js code:</p>
  
  <pre><code>// server.js
  
  const express = require("express");
  const app = express();
  const bodyParser = require("body-parser");
  const PORT = 5000;
  const cors = require("cors");
  
  app.use(cors());
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  
  app.get("/createaccount", (req, res) =&gt; {
    console.log("test");
    res.append("Access-Control-Allow-Origin", ["*"]);
    res.append("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
    res.append("Access-Control-Allow-Headers", "Content-Type");
    res.send("testComplete");
  });
  
  app.listen(PORT, function() {
    console.log("Server is running on Port: ", PORT);
  });
  </code></pre>
  
  <p>CreateAccountjs code:</p>
  
  <pre><code>// Create.js
  
  import React, { Component } from "react";
  import axios from "axios";
  import { Button, FormGroup, FormControl, FormLabel } from "react-bootstrap";
  
  export default class CreateAccount extends Component {
    constructor(props) {
      super(props);
      this.handleSubmit = this.handleSubmit.bind(this);
      this.handleChange = this.handleChange.bind(this);
  
      this.state = {
        email: "",
        password: ""
      };
    }
  
    handleChange = e =&gt; {
      this.setState({
        [e.target.id]: e.target.value
      });
    };
  
    handleSubmit = e =&gt; {
      e.preventDefault();
      const data = {
        email: this.state.email,
        password: this.state.password
      };
      fetch("http://localhost:5000/createaccount", {
        method: "POST", // *GET, POST, PUT, DELETE, etc.
        mode: "cors", // no-cors, cors, *same-origin
        headers: {
          "Content-Type": "application/json"
          // "Access-Control-Allow-Origin": "*"
          // 'Content-Type': 'application/x-www-form-urlencoded',
        },
        redirect: "follow", // manual, *follow, error
        referrer: "no-referrer", // no-referrer, *client
        body: JSON.stringify(data) // body data type must match "Content-Type" header
      }).then(res =&gt; console.log(res));
    };
  
    render() {
      return (
        &lt;div className="CreateAccount"&gt;
          &lt;form onSubmit={this.handleSubmit.bind(this)}&gt;
            &lt;FormGroup controlId="email"&gt;
              &lt;FormLabel&gt;Email&lt;/FormLabel&gt;
              &lt;FormControl
                type="email"
                value={this.state.email}
                onChange={this.handleChange.bind(this)}
              /&gt;
            &lt;/FormGroup&gt;
            &lt;FormGroup controlId="password"&gt;
              &lt;FormLabel&gt;Password&lt;/FormLabel&gt;
              &lt;FormControl
                value={this.state.password}
                onChange={this.handleChange.bind(this)}
                type="password"
              /&gt;
            &lt;/FormGroup&gt;
            &lt;Button type="submit"&gt;Sign up!&lt;/Button&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      );
    }
  }
  
  </code></pre>