Connection between React and Node in the live server

Here I’ve uploaded the NodeJS API- It’s working fine. Source code of the API- github .com/mofizul21/React-Blog-API

From here- Blog App I’m trying to register. But I see the CORS problem. Later I’ve used the npm i cors module in the Node app, now I see POST 404 in the browser console.

I’m using Namecheap hosting. The app is working fine in localhost. But creating problems in the live server. On the homepage it should display blog from MongoDB, also that’s not working.

Have you any idea to fix the problem?

Seems like you are missing the /api/ part of the route path in your frontend code.

@lasjorg I’ve built the React app with a custom URL So there is no chance to miss the /api/.

Where/how are you hosting this?

Also, are you sure the API is actually running? If I look at the package.json file you only have this for the start script "start": "nodemon index.js" and you do not have nodemon in the dependencies.

The start script should be running node, you can have a dev script for the local environment.

"scripts": {
  "start": "node index.js",
  "dev": "nodemon index.js"

Not really sure what you mean by this.

@lasjorg Yes, I’m 100% sure that the NodeJS is running on the Namecheap shared hosting and trying to get data from there. React app is also from the same hosting.
Namecheap has tools for running NodeJS, Python apps.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.