title: Error: "Request failed with status code 500" while posting to API firebase
body: <p>Error: "Request failed with status code 500" while posting to API<br>
  Until here i was getting cross origin error now when i added app.use(cors()) getting internal error 500<br>
  Made the below things to my code</p>
  
  <pre><code>  const express=require('express')
      const app=express();
      app.use((req, res, next) =&gt; {
          res.header('Access-Control-Allow-Origin', '*');
          next();
        });
      app.use(cors());
  
     app.post("/project",(req,res)=&gt;cors(req,res,()=&gt;{
      const newProject={
          title:req.body.title,
          description:req.body.description,
          status:req.body.status,
          startdate:req.body.startdate,
          enddate:req.body.enddate,
          supervisor:req.body.supervisor,
          createdAt:admin.firestore.Timestamp.fromDate(new Date())
      }
      admin.firestore().collection("Projects")
      .add(newProject)
      .then(doc=&gt;{
          return res.json({message:`Project ${doc.id} created successfully`})
      })
      .catch(err=&gt;{
          res.status(500).json({error:`Something went wrong, ${err}`})
      })
  }))
  </code></pre>
  
  <p>Below is the client side code :</p>
  
  <pre><code>const newProject=JSON.stringify({
      title:project.name,
      description:"",
      status:project.status,
      startdate:project.startdate,
      enddate:project.enddate,
      supervisor:project.supervisor,
  })
  axios.post("https://us-central1-flair-d7b59.cloudfunctions.net/api/project",newProject)
  .then(res=&gt;{
    this.setState({ open: false });
    Swal.fire({
      icon:"success",
      toast:true,
      title: res,
      position: 'top-end',
      showConfirmButton: false,
  
      showClass: {
        popup: ''
      },
      timer: 2500
    })
  })
  .catch(err=&gt;{
    console.log(err)
    this.setState({loading:false})
    Swal.fire({
      icon:"error",
      toast:true, 
      title:"Something went wrong, Please try again",
      position: 'top-end',
      showConfirmButton: false,
  
      showClass: {
        popup: ''
      },
      timer: 2500
    })
  })
  </code></pre>
  
  <p>tried a lot but no solution. Thank you</p>