skip to Main Content

I want to merge two projects: one for the React frontend and the other for the NodeJs Express backend. I am using Android Studio to preview my front-end application on a phone emulator. I am not sure if you have any ideas on how I can get everything to work together.

I started by copying the front-end project and putting it at the root of the back-end project. Then, I set up a variable in the package.json file to be able to start the front-end from the back-end ("client": "cd my_frontend_project && npm start"). As for the next steps, I’m lost and I really don’t know what to do.
Should I create a single file to start this connection, or several, knowing that my project comprises several pages/functionalities, and how do I set up this connection?

2

Answers


    1. first of all you need to start the backend and in case it is not implemented in backend the you should implement Cors,(which is a middleware)
    2. you need to test the api using postman
    3. end
    Login or Signup to reply.
  1. to understand all of your code how the flow works inside some the functions try to write consoles for example: console.log("auth-middleware") ,
    console.log("error handler")

    first of all start both of them Frontend and Backend
    second check the port number that they are running
    so in backend (Nodejs)
    in index.js (the file that start the server)
    try to set up the cors like this:

    app.use(cors({
    origin: ['http://localhost:8080',]
        methods: ['GET','POST','DELETE','UPDATE','PUT','PATCH']
    }));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search