React/Express app not using proxy in package.js - node.js

Creating my first React (frontend)/Express (backend) app (3000:5000 respectively). Both are running but when I setup a proxy in my frontend package.js, the frontend is still trying to grab localhost:3000 and is not using the proxy to request data from the backend. I noticed that my package-lock.js doesn't the proxy reference like my package.js does. Is package-lock.js not updating? Or is this another issue?
"name": "frontend",
"proxy": "http://127.0.0.1:5000",
"version": "0.1.0",
"private": true,
"dependencies": {..
I deleted the package-lock.json and regenerated it but no proxy mentioned in it again?

Related

problem to link react app to nodejs server on ubuntu

im hosting my react app to hostinger single host and my nodejs app to hostinger vps so my react app work normally in localhost but after build and host it cannot get any data from node server.
this is how i link with proxy:
{ "homepage": "https://cubexpro.net/", "version": "0.1.0", }, "devDependencies": { "#iconify/react": "^4.0.0", "node-sass": "^7.0.3" }, "proxy": "http://45.132.240.106" }
im trying to add port to the link but nothing is working

setting entry-point for react app with node

I have a static web-page that I want to be the home-page (the one that opens when you run npm start). Inside my package.json, I have:
{
"name": "app-name",
"version": "0.1.0",
"main": "public/home-page/home-page.html",
"private": true,
"dependencies": { ...
where public/home-page/home-page.html is the path from the directory of the package.json to the HTML that I want to open initially. This isn't working.
I created the react page with create-react-app and I put my static webpages from before into public and now want one of them to serve as the entry point of the program.
What am I doing wrong and/or how can I accomplish what i am trying to?

How to deploy React App client and Node Server to cPanel

I am trying to deploy a react app and a node server to my domain http://cv-devlabs.com/ with cPanel but failing to run. Most of the time I'm getting a "server responded with the 404 error".
I have tried methods from "hosting react app and express server cpanel" and "How to deploy a react app on cPanel?" and failed at both. I'm assuming I did something wrong here.
My file structure is:
Root-Folder--
-client
--build
--node_modules
--public
--package.json(client)(content added below)
-.gitignore
-package.json(server)(content added below)
-procfile
-server.js
Package.json (client)
"name": "client",
"homepage": "http://cv-devlabs.com/vidci-vid2/",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:8000",
Package.json(server)
{
"name": "vidci-vid",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"socket.io": "^2.3.0"
},
"scripts": {
"start": "PROD=true node server.js",
"postinstall": "cd ./client && yarn"
}
}
This is working fine on Heroku but on cPanel, it's not. The whole project can be found at https://github.com/ConsultVerraton/vidci-vid.git
Thanks to anyone who can help and thanks to anyone who can try. Do let me know if more information is needed.
Thanks
You cannot host a node.js app in most providers working with cpanel. If you want to host a node.js app you should deploy it on a vps. You can follow this tutorial for example:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
But in these cpanel providers, you could host a static react app (for example an app build with create-react-app). This kind of app does not need node.js at runtime. So you can build the assets and push them to your cpanel host.
You can follow this tutorial:
https://dev.to/crishanks/deploy-host-your-react-app-with-cpanel-in-under-5-minutes-4mf6
Yes you can, but it depend if the host provider allow it.
I'm actually running a express server on a cPanel account.
I didn't found the official documentation of cPanel but this is a pretty good one: How to create a Node.js application with cPanel using the Node.js Selector
If your looking to do it in command line, this the official documentation from cPanel :How to Install a Node.js Application.
I don't know about react but for anyone who wants to know how to deploy node js app to Cpanel this is a good source for him, this explains thoroughly how to deploy node js app to cpanel please check this

NodeJS - Deploy socket server in Jelastic

I have a socket server that I want to deploy in my Jelastic NodeJS setup. It is made of 2 files, being server.js the main file, the one started/opened by node, and worker.js the file opened as a child process by the server when required (each child handles a socket).
I never deployed a project via Jelastic or any other cloud PaaS/hosting. How should I proceed to do this?
I know that I have to write the package.json, but that's all I know.
So far, this is what I've got:
//package.json
{
"name": "Myserver",
"version": "1.0.0",
"description": "My Server",
"main": "server.js",
"dependencies": {
"microtime": ">=1.2.0",
"microseconds": ">=0.0.2",
"mysql": ">=2.5.4",
"point-in-polygon": ">=0.0.0"
},
"devDependencies": {},
"scripts": {
"start": "node server.js"
},
"author": "Magister"
}
I searched on their docs but all they have is how to deploy a WEB application, but my server is not web-related, so that information is not relevant.
Any suggestions?
Do you have a public IP? Most likely WebSocket app won't work behind the proxy so far

Uploading Node.js app to cloudfoundry withour express error

Im trying to upload a node.js app into cloud foundry, im not going to use Express Framework, but when doing "vcm push" Im getting this error.
Uploading Application:
No such file or directory - /Users/jtomasrl/Code/node/pronto/node_modules/express
here is my package.json
{
"name": "karaoke-api",
"version": "0.0.1",
"dependencies": {
"pronto": "*",
"pronto-mongodb": "*"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
Just for the sake of providing an "answer", when this situation does arise, it's worth emptying node_modules/.bin or even removing node_modules itself and re-installing modules with;
npm install

Resources