set cookie on a react app running on different port from express api server running on different port on same machine but not on localhost - node.js

I am running both the react app on 0.0.0.0:5000 and expressjs api server on 0.0.0.0:3000 .i.e. instead of accessing them via localhost I am using my machines ip on home network which is
192.168.0.7:5000 (for react app)
192.168.0.7:3000 (for api server)
I have to test this on different devices connected to my home wifi. However the app is unable to allow set cookie
this set cookie was blocked because its domain attribute was invalid with regards to the current host url
as per suggestions over net added proxy to package.json of react app
and in changed cookie domain in api server setting to 192.168.0.7:5000 (address for react app)
below is the screenshot of the network request in chrome

Related

Connect domain to nodejs server hosted on vps instead on ip + port

i have 2 react apps and a nodejs server (express and websocket) running on port 8000.
the express server is for generating random links and the websocket for sending real-time messages between the apps.
my apps worked perfectly after hosting on my vps server but after connecting letsencrypt ssl to both react apps, they don't work anymore because i have to connect to a websocket with secure connection.
so i want to connect the nodejs server with a subdomain i have from namecheap.
i have tried pointing the subdomain i got for the server to the ip of the vps but i don't know what to do after that.
should i create a new file just like i did for the previous apps in the sites-available directory, listen to port 8000, set server name to the intended subdomain and run a proxypass to the same subdomain?
This is my first time hosting on a vps server, i'm very confused at the point but my server works well when i just type in ip:8000 on my brower

How to make an HTTP request from a remote web client hosted by an npm server to a private port of a backend server running behind the Linux Firewall

There is a front-end npm server hosted on a public port 80 in my production environment. I can launch a remote web browser client of this front-end server using its public hostname, e.g., http://hostname:80, and successfully load the webpage.
The Javascript in this app makes HTTP GET/POST requests to a back-end server to fetch some data on the URL: http://hostname:5000. This back-end server is running on the same production environment but on a private port, e.g., 5000, i.e., this port will not be visible outside the firewall.
As I understand it, this HTTP request is essentially made from the remote web browser client sitting outside the firewall. Due to the Firewall (UFW) policy, any request made from this client on private port 5000 gets blocked.
I do not want to allow the private port 5000 in the UFW, and I do not want to run the back-end server on a public port of the production server.
What are the solutions for this?
I have heard about the Nginx proxy server which redirects client connections on a public port (80) to a Node application running on a different port (3000).
Reference: https://blog.logrocket.com/how-to-run-a-node-js-server-with-nginx/
However, I am not certain if the Nginx server would be able to handle the client requests beyond the UFW rules.
The majority of request information is sent to the backend from the proxy.
A request sent through the nginx proxy will act like a request directly to the backend.
Some fields may not be passed, for example:
From nginx.org:
By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed

How build to deploy node app to http server

Is there any way to use express or other nodejs librarys to to design an api and deploy it pasting files as a resource path in a web server just like react.
My web server just listen on ports 80 and 443.
I have pages on domain.com/page1 domain.com/page2.
and i want to deploy an api listening on domain.com/page3 but i cant install a nodejs server and proxy requests to page3 to it.
Thanks a lot
There can be only one web server listening on a given port. You can directly "listen to a path", only a port.
So, if you already have an existing web server running on ports 80 and 443, then these are your options.
Modify your existing web server to add your API server code to it so it can handle requests for http://yourdomain.com/page3 and https://yourdomain.com/page3 directly with your API.
You can add some middleware to your existing web server to make it a proxy for http://yourdomain.com/page3 that will redirect requests to your http://yourdomain.com:3000/page3 Express-based API server.
Run your own Express-based API server on your own separate port and access the API server directly via the separate port such as http://yourdomain.com:3000/page3.
You can install a proxy such as nginx in front of your existing web server and have it redirect incoming requests to http://yourdomain.com/page3 and https://yourdomain.com/page3 to the separate port that your Express-based API server is running on.

Deploy nodejs express on AWS windows server

I deplyoed my nodejs application on a AWS server with windows server as OS. The application is a simple express server running on https port 443. The application is accessible through localhost, but I can access the app through public IP.
Here are a few things I tried:
IIS with urlrewrite like so (https://dev.to/massivebrains/deploying-node-express-app-on-a-windows-server-2l5c)
iisnode
I am still not able to access my app. I setup up inbound rules in my firewall for the port and nodejs itself.
The issue was simply in my security group. I had set up the IP addresses I was expecting, but one was missing. It is working now.

Can't access nodejs from external ip in digital ocean

i want to deploy an vue application with express backend both on one virtual machine on digital ocean . I have successfully deploy vue application and i am able to access it with external ip but express backend is not working i started the server with pm2 but vue application which is hosted and working properly is not able to connect to express bakcend also i am not able to access it through external ip like this :3000
i have enabled port 3000 on firewall my mongo db is working and server is properly doing there stuff

Resources