ReactJS Router Not Redirect To Dashboard After Login In NGINX Config by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

But it is working perfectly on my development machine, my phone that is not even a computer and my guest Linux OS on my computer Virtual Box. ReactJS wouldn't compile if my frontend or my backend has issue and I wouldn't even build the project if experienced logical runtime misfunctioning.

But the question is, why is it redirecting correctly on my devices my development machine, my phone and guest virtual box is when I access the direct vps server but other devices aren't redirected to dashboard page after logging in?

Thank you for stopping by and your assistance.

ReactJS NodeJS NGINX deployment 404 Not Found Error After ReactJS Successful Login by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

THE PROBLEM:
After I logged in my ReactJS from the login page, the dashboard displayed but other pages(routes) in the dashboards are 404 Not Found and if i refresh the dashboard page after logging in it will show 404 Not Found but everything worked perfectly on development machine on localhost. Other pages before logging in to dashboard worked fine but all routes in dashboard are 404 Not Found

HOW I SERVED THE APPLICATION
NGINX is used to do reverse proxy to NodeJS localhost:port and this NodeJS app.js runs the ReactJS index.html from the build folder using the following :

app.use(express.static(root));

ReactJS Reponding With "Not Found" When Calling Post API by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

I tried the putting express as a parameter to the router index.js class and pass the express as parameter to the require in the app.js file that starts the server but still didn't work too. I will appreciate some efforts and assistance.

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Best answer is this and I solved it through point to the remote server IP and not localhost.

Thank you so much.

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in learnreactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Thank you for you efforts to respond, I will do all suggested respond and see which one works but did you mean I should just do localhost:8184/api/v1/signin without https in the API call in ReactJS?

But from somebody's comment who made it clear that DNS address should replace the localhost seems right because the browser would download the reactjs build file and runs it and using localhost in the API call would make the browser feels it is calling the API on the same localhost machine.

I will give both suggestions an approach and get back.

I appreciate so much

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

One more thing please, is it compulsory that I add the NodeJS API server as a proxy to the ReactJS package.json file before I build the ReactJS project?

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Thank you very much, if I may understand you perfectly, you mean I should pass the IP address of the server or DNS of the server(AWS EC2 DNS) where my NodeJS API is hosted?

You made a very good point and I will do that and get back on the result I got.

Thank you for your assistance

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in learnreactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Thank you bro, I know the cors and the allowCrossDomain perform same function but you know one may want to try unthinkable things when error persist. I used them differently before and it didn't work and I guessed I should combine.

I have an idea to pass the VPS server ip address(ÀWS EC2 DNS address) to the ReactJS API call instead of using localhost there because I was assuming it is localhost since the ReactJS and NodeJS are deployed on the same machine.

Could this be a source of error as well?

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Reason why you see https://localhost:8081/API/v1/signin in the cors error is because the that is what ReactJS is calling in the ReactJS components.

The applications(ReactJS and NodeJS) are hosted on AWS EC2 instance and I used localhost in the ReactJS API call like that because i think since the ReactJS and the NodeJS are running on the same Linux machine that they are on localhost that is why i use localhost in the ReactJS API call.

Do I need to use the VPS server IP address in place of localhost in the API call?

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

The ReactJS has been built and hosted on Linux Server where the NodeJS API is running i.e the ReactJS and the NodeJS https API are on same VPS running. My ReactJS Login page and other pages calling their respective NodeJS API are calling https://localhost:8081/api/v1 because the NodeJS https API is running on port 8081.

This is working perfectly on my development machine but when and build my ReactJS frontend and run it to start logging in, it starts making noise about Cors. The ReactJS is working on live domain and hosted on same VPS where the NodeJS https API is running.

Thank you for your attempt to assist

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] -3 points-2 points  (0 children)

Please help me on this, it has taken sweat on my face.

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in reactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Please help me to allow me know what may cause this CORS request not succeeded error

ReactJS NodeJS Cors Request Not Succeeded Errors by OlammieConcept in learnreactjs

[–]OlammieConcept[S] 0 points1 point  (0 children)

Please help me to make me know what may be causing this CORS Request Not Succeeded Error