Routing 404 error on my app

Hello,

I’m trying to deploy my application onto Netlify, this is the domain https://night-in.xyz/

I have it connected to CI/CD on Git. I also have a netlify.toml file set up for the env variables, and headers for cors since my front and backend are in the same deploy.

[build]
command = “npm run build”
publish = “build”

[[headers]]
for = “/"
[headers.values]
Access-Control-Allow-Origin = "

Access-Control-Allow-Methods = “GET, POST, PUT, DELETE, OPTIONS”
Access-Control-Allow-Headers = “Authorization, Content-Type, x-ms-request-root, x-ms-request-body, x-ms-request-id”

Environment variables

[build.environment]
DB_HOST = “##”
DB_USER = “##”
DB_PASSWORD = “##”
DB_DATABASE = “##”
DB_PORT = “##”

I also have the publish directory to “build” which is located in my root dir of my React app.

However with all of these checked, im still getting a Night-In error and i cannot figure out why.

If anyone can help me out i will appreciate it.

Hi @ish , thanks for the post.
Do you get the 404 when you navigate to a specific page, when you try to login, or when you refresh your page after visiting?

Thanks.

Hi clarnx,

Thanks for getting back to me.

At the landing page is a simple login button where my client side function on the login button sends an axios post request to my backend folder where it holds the code to get the information from my database.

On this axios route i have it set to https://night-in.xyz/ where my backend server recieves it at

app.post(“/”, handleLogin);

Locally this works fine if i have my client side route to http://localhost:3001.

This is the error message below:

POST https://night-in.xyz/ 404 (Not Found)

Thanks.

Hi @ish , thanks for the feedback.

The above does not because your api route is not correct.
Kindly take a look at the forum link below to see how to properly deploy Express applications to Netlify.

Also take note of the below. It has been quoted from Netlify’s Functions Documentation at Get started with functions | Netlify Docs

These formats would deploy a synchronous function that can be called on the following endpoint: /.netlify/functions/hello . The endpoint is relative to the base URL of your site. Here are some example full endpoint URLs: yoursitename.netlify.app/.netlify/functions/hello for a site using the default Netlify subdomain or www.yourcustomdomain.com/.netlify/functions/hello for a site using a custom domain

Thanks.