ReactJS client and ExpressJS backend application production problems - javascript

I am new in reactjs and nodejs.I made an application with react frontend and express backend. There are axios post and get requests for get data from mssql database via express.
When the project in production level, I write the IPv4 address and port for access dashboard from another device in local network. After build,when I use for example localhost:5000 for requests, I can see all datas which are come from database in the device which react project running but with this I cant see datas from android phone in local network.
What should I do? Isn't there any other way than writing a static IP address? This project can be run different machines.
I am sorry for my spelling mistakes.

Related

Can I run my Node.js/Express backend and React.js frontend together in the same file structure?

I am making a web app that uses a Node.js/Express backend and a React.js Frontend. Right now I have my Node.js code that validities login/registration credentials in a separate folder running on localhost:5000 while my React.js frontend login/registration form code is running on localhost:3000.
My question is would it be easier to put both my frontend and backend code into one file structure so I don't have to send the data from my form to my backend running on another domain so for example both my Node.js and React.js code would be running on localhost:3000 and would just send the form information to the Node.js files that validate the user credentials instead of having to use a fetch method to send my form data to the backend. Is this even possible?
Yes, it is possible, you can use Express to serve your static files (frontend ReactJS) and also your backend routes. Take the following Github repository as an example.
https://github.com/Bikranshu/express-react-boilerplate
That is possible, A monolithic architecture with express and reactjs (https://medium.com/#sesitamakloe/easy-express-react-monolith-chapter-1-a1567c6ff483)

How to start big nodejs project virtual classroom?

Developers i'm a nodejs developer with a experience of 1.5 years working in the company my question is i'm doing a project which is called a virtual classroom like a webinar platform where chat support, drawing and etc functionalities are available, so from last 2 month had been done of working in project i had gone through the each component directory and file with it's documents also they have used of docker, redis, proxy server, nginx, session, mongodb these kind of services and it's working fine on server end side but can't able to stablish on my local machine and it's a linux based project where have numbers of powershell files with PM2 library to make it run... so i followed a docs with some code also i success to make the service on and registered a local domain also in hosts file or nginx custom configuration it is working fine... but when i hit my ulr on browser with the local domain it not going to any of the route....
Example - like if we make a node simple project with hello world and it will working on 4500 port so we write localhost:4500 and it will print our responce on browser
but if the run my project through a PM2 or a simple node app.js bcoz this app.js have connected with all nodes services and virtual classroom and you the linux platform we don't need to make serivice on it's by default in runing state monogoDB, redis, docker, nginx but the real question is while firing the command node app.js it shows some json and told port:2178 but when in hit this on browser localhost:2178 not responce to GET request why??? but there is route called localhost:2178/landing/session/v1/classid(which is encrypted code) this url not working what to do ??

How to connet to the mysql server in zeit-now

I use zeit-now to deploy my website.
But I can't connect to my MySQL server.
I'm sure my MySQL server is able to be connected on my machine.
Here is my repo.
Any solution?
In the FAQ it says
Now itself focuses on being the best platform for serverless hosting. This means that the workloads we handle are static or stateless.
Still, you're trying to connect to your database on localhost. Although running a database instance in a docker container might be an option for a staging system, it definitely is not for production systems, since you will lose the data when you restart/redeploy. And you don't seem to startup a docker container in your deployment.
You should use a cloud database provider instead:
Use Cloud Databases that offer secure (preferably HTTPS-based) gateways, for example: Azure CosmosDB, MongoDB, Atlas, Firebase, Google Cloud SQL

Connection mysql credentials ElectronJs

I am currently using Mysql in my electron application, so I started to verify the .asar file when I compiled it, I could see that all the application code is shown, so I think the Mysql connection would be very vulnerable, there is some way to correct this?
Image:

How to create a react-redux app with node server as backend?

I am trying to create a react-redux app using node server as backend. Is it possible to make the node server serve the react-redux app instead of running react-redux using dev server a=in one port and node on another port?
Need some idea to start with. Thanks in advance:)
Yes.. it is
you can serve you react app on '/'
and listen for API request in another route
so you don't have separate codebase for the react app and the api backend code
You can use express to serve the react app on a particular route
i.e my-app.com/
then serve backend related content on another route
i.e
my-app.com/api
so when a request is made to my-app.com/ express serves express serves backend resource or API
There are a few steps I take when creating an express/react app together. I'll create a server and a client directory. The client dir is created with create-react-app and the server can be created via express-generator for example. My project dir (the one that contains both of them) is basically just glue that melds the two together. In the client app, I'll add proxy:localhost:3001 (or whatever port your express api is running) and I use concurrently to run both servers (client and server - as client is being run by webpack-dev-server) at the same time. They run as separate servers during development, but when I make an api call, it's as if I'm making it directly to the express server itself.
The only other thing to worry about is deploying the application. You can use the build command that comes with create-react-app and copy that over to the public directory in your express application that is served up via express.static.
Here's a quick example to take a look at:
https://github.com/overthemike/heroku-skeleton
This is an useful doc for redux SSR setup. This helps avoiding running client and server at two ports.
Redux SSR

Categories

Resources