title: I have an express app deployed on Heroku but I have 404 (not found) error
body: <p>everything works in my localhost:3000 and using a baseUrl of localhost:5000</p>
  <p>I changed my baseUrl to the deployed site(<a href="https://mongodb-newsapi.herokuapp.com" rel="nofollow noreferrer">https://mongodb-newsapi.herokuapp.com</a>) but I got an error saying that my site is not found.</p>
  <p>Failed to load resource: the server responded with a status of 404 (Not Found)
  POST <a href="https://mongodb-newsapi.herokuapp.com/api/login" rel="nofollow noreferrer">https://mongodb-newsapi.herokuapp.com/api/login</a> 404 (Not Found)</p>
  <p>this it my fetchDataApi:</p>
  <pre><code>import { axiosInstance } from './axios';
  
  export const getDataApi = async (url, token) =&gt;{
  
      const res = await axiosInstance.get(`/api/${url}`,{
          headers : {Authorization : token}
      })
      return res;
  }
  
  export const postDataApi =async (url, post, token) =&gt; {
     
      const res = await axiosInstance.post(`/api/${url}`, post ,{
          headers: {Authorization: token}
  
      })
      
      return res;
      
  }
  
  export const putDataApi = async (url , post, token) =&gt; {
  
      const res = await axiosInstance.put(`/api/${url}`,post,{
          headers :{Authorization: token}
      })
      return res;
  }
  export const patchDataApi = async (url , post, token) =&gt; {
  
      const res = await axiosInstance.patch(`/api/${url}`, post , {
          headers :{Authorization: token}
      })
      return res;
  }
  export const deleteDataApi = async (url , token) =&gt; {
  
      const res = await axiosInstance.delete(`/api/${url}`,{
          headers :{Authorization: token}
      })
      return res;
  }
  </code></pre>
  <p>This is my baseUrl:</p>
  <pre><code>import axios from 'axios';
  
  export const axiosInstance = axios.create({
  
      baseUrl: &quot;https://mongodb-newsapi.herokuapp.com/api&quot;
  });
  </code></pre>
  <p>This is my server.js:</p>
  <pre><code>require('dotenv').config();
  
  const path = require('path');
  
  const express = require(&quot;express&quot;);
  
  const mongoose = require('mongoose');
  
  const cookieparser = require('cookie-parser');
  
  const authRouter = require('./routers/authRouter');
  
  const userRouter = require('./routers/userRouter');
  
  const app = express();
  
  app.use(express.json())
  
  app.use(cookieparser());
  
  app.use('/api', authRouter);
  
  app.use('/api', userRouter);
  
  app.use(express.static(path.join(__dirname, &quot;/client/build&quot;)));
  
  app.get('*', (req, res) =&gt; {
      res.sendFile(path.join(__dirname, '/client/build', 'index.html'));
  });
  </code></pre>
  <p>I didn't add the mongoose.connect because I have my account.</p>
  <p>and this is the authCtrl:</p>
  <pre><code>const Users = require(&quot;../models/userModel&quot;);
  
  const bcrypt = require('bcrypt');
  
  const jwt = require('jsonwebtoken');
  
  const authCtrl = {
  
      register: async (req, res) =&gt; {
          try {
  
              const { fullName, userName, email, password } = req.body;
  
              const newUsername = userName.toLowerCase().replace(/ /g, '');
  
              const user_name = await Users.findOne({ userName: newUsername })
  
              if(user_name) return res.status(400).json({ msg: 'This UserName Already Exist.' })
  
              const Email = await Users.findOne({ email: email })
  
              if(Email) return res.status(400).json({ msg: 'This Email Already Exist.' })
  
              if(password.length &lt; 8) return res.status(400).json({ msg: 'Password must be atleast 8 Characters.' })
  
              const passwordHash = await bcrypt.hash(password, 15);
  
              const newUser = new Users({
  
                  fullName, userName:newUsername, email, password:passwordHash
              })
  
              const access_token = createAccessToken({id: newUser._id});
  
              const refresh_token = createRefreshToken({id: newUser._id});
  
              console.log({access_token, refresh_token})
  
              res.cookie('refreshtoken', refresh_token, {
                  httpOnly: true,
                  path: &quot;/api/refresh_token&quot;,
                  maxAge: 24*30*60*60*1000
              })
  
              await newUser.save(); 
              
              res.json({
                  msg: &quot;Registered Success&quot;,
                  access_token,
                  user: {
                      ...newUser._doc,
                      password: ''
                  }
              })
  
          } catch (error) {
              res.status(500).json({ msg: error.message })
          }
      },
      login: async (req, res) =&gt; {
          try {
          const {email , password} = req.body;
  
          const user = await Users.findOne({email})
          .populate(&quot;friends following&quot; , &quot;-password&quot;)
  
          if(!user) return res.status(400).json({msg: 'User does not exists'})
  
          const isMatch = await bcrypt.compare(password,user.password);
          if(!isMatch) return res.status(400).json({msg: 'User Password is incorrect'})
  
          const access_token= createAccessToken({id: user._id});
          const refresh_token= createRefreshToken({id: user._id});
          
  
          res.cookie('refreshtoken', refresh_token,{
              httpOnly: true,
              path:'/api/refresh_token',
              maxAge: 24*30*60*60*1000  
          })
  
          
  
          res.json({
              msg:&quot;login sucess&quot;,
              access_token,
              user:{
              ...user._doc,
              password:''
              }
          })
  
      } catch (err) {
          return res.status(500).json({msg: err.message})
      }},logout: async ( req, res ) =&gt; {
  
          try {
              res.clearCookie('refreshtoken', {path: '/api/refresh_token'})
  
              res.json({msg: &quot;Logged out&quot;})
  
          } catch (error) {
  
          return res.status(500).json({ msg: error.message })
          }},generateAccessToken: async (req, res) =&gt; {
  
      try {
          const rf_token = req.cookies.refreshtoken;
              
             
          if(!rf_token) return res.status(400).json({msg:&quot;please login now&quot;})
  
          jwt.verify(rf_token, process.env.REFRESHTOKENSECRET, async(err,result)=&gt;{
              if(err) return res.status(400).json({msg:&quot;Please login now&quot;})
  
              const user = await Users.findById(result.id).select(&quot;-password&quot;)
              .populate(&quot;friends following&quot;)
  
              if(!user) return res.status(400).json({msg:&quot;user does not exist&quot;})
  
              const access_token= createAccessToken({id: result.id});
  
              res.json({
                  access_token,
                  user
              })
              
          })
      } catch (error) {
          res.stauts(500).json({msg: error.message})
      }},}const createAccessToken = ( payload) =&gt;{
  
      return jwt.sign(payload, process.env.ACCESSTOKENSECRET, {expiresIn: &quot;1d&quot;})}const createRefreshToken = ( payload) =&gt;{
  
      return jwt.sign(payload, process.env.REFRESHTOKENSECRET,{expiresIn: &quot;30d&quot;})}module.exports = authCtrl
  </code></pre>
  <p>this the github repository:</p>
  <p><a href="https://github.com/Noobieprogrammer69/mongodb-heroku" rel="nofollow noreferrer">https://github.com/Noobieprogrammer69/mongodb-heroku</a></p>