How to hot reload on netlify? - node.js

Netlify just as example, same question with CloudFlare Pages etc.
In the past I setup my own server with node and react/vue.
I have my node setup on a server because I don't want to install node and node packages on my local machine.
When I was developing I SSH into the server with port forwarding.
So I ran a dev server on port 8888 (npm run dev) on the server and opened http://localhost:8888 in my local browser.
When I make a change to the files I can immediately see the effects without running npm run build.
I am thinking about using a service like netlify because its the right thing to do? But how can I see the changes I make without actually running build?
Is this even possible or do you use theses service only when you are building a website that rarely changes? I am probably missing something. But not sure how to proceed.
I don't know what's the right way. I am very open to suggestions.
Edit: These services that I mentioned are meant for build only. See answer below. I am still leaving this question so people can post suggestions.

You cannot do this. Those services are only for hosting the build version of your app. You have to develop it locally and push the build to these services.
Why would you even want to run a development version online?

Related

Deploy a next.js project locally without code on the machine

I am trying to deploy a Next.js Web App in combination with a node.js backend on a windows PC.
I know there are vercel and Heroku, but the application has to run even without a connection to the Internet. (My friend has a bar and he wanted a small ordersystem and I don't want him to be able to access the Code.)
I know I could just go "npm run build" --> "npm run start".
But I don't want the code locally on the machine because i am scared of plagiarism.
Is there a way to deploy this locally via Git? So the software runs on the local machine without the code beeing there?
Is it possible to create CI/CD, so it listens to new pushes on git?
Any help would be nice đŸ˜…
Get a computer installed on the businesses’s local network, encrypt its disk, and install your app on it.
You can also automate deployments with git’s postreceive hook.

How to deploy React.js with Node backend in IIS?

I have an application built with Create React App that I want to use Node.js as a backend to load data from a database. Basically, I want Node to load the data and then use Create React App to do stuff with it. To do so I used this tutorial: https://www.freecodecamp.org/news/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0/. I have set up a working development environment where I have all the Create React App in a client folder, a server.js that loads the data (from MS SQL Server if that's relevant), and a proxy set in client/package.json (CRA's package.json) for the port that the node app is running on (5000 in my case). I then run yarn dev and these two servers run together and talk to each other and everything works great.
The issue is deploying. My organization uses IIS. From what I can gather Node and IIS are not the ideal combination but IIS is what we use for everything. I would like the server.js and the CRA to be in the same folder and to basically function like one app as much as possible (I know that Node will need to run its own server). I would also like a setup that can be easily changed or moved to another machine. What I've done thus far is:
Set up a single application with a client folder, which is the build for CRA, and then server.js in the root
In my react code, made API calls to http://localhost:5000 (in the development environment I could do fetch('api/somestuff') but to make it work in production I needed to do fetch('http://localhost:5000/api/somestuff') )
Installed pm2 and used it to run server.js and start the Node server
This worked, however I'm wondering whether this is the optimal way to do things. This worked on my local machine but I don't know what will happen when I put it on our production machines. Will the Node server block other applications? Will it stay running no matter what or might it crash? Ultimately this is going to be deployed in a multi-server environment where we have 2 load-balanced servers with identical code that are put through an F5 to form a single URL--will this impact anything?
I'm pretty new to programming so bear with me, I'm sorry if this question was confusingly phrased.
I suggest you install ARR to work with IIS as a reverse proxy, which can forward the HTTP request to the backend NodeJS server.
Besides, for cross-domain request forwarding in the rewrite action type, we need to install Application Request Routing, and enable the proxy functionality.
Here are two examples of applying this feature, please check it.
How to successfully run node server with IIS?
ASP.net URL Rewrite subdirectory to external URL
Feel free to let me know if there is anything I can help with.

How to host a React App on Standalone Server

I have a stand alone server that will only be connected to a lan without outside internet access. I am new to hosting so I am lost as to what to use and how to do it.
I have run my react app using npm start. But how do I configure node to start up a react app when the stand alone server starts?
Is there some other windows based host that is easier to configure to run a React app?
I would probably use a Linux server distribution to achieve this. Quite easy actually but not sure how to do that on a Windows machine, unfortunately. You can simply Google for "How To Setup A Web Server And Host Website" I am sure there are a lot of guides and tutorials

What is the best way to execute nodejs app on a server?

Is there a panel for run node app?
Just have to run it on the server?
Set everything up manually?
Manual installation xngin ,apache ,mongodb , ...
Manual Server Configuration.
Is there a similar panel Vesta?
There are services like Heroku or Digital Ocean where you can get a node server up without having to do a lot of setup (i.e. not touching apache or nginx etc.). I think that's what you're looking for.
https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
Honestly after creating a social network in React, PHP and mysql I would recommend uploading the build files to a conventional hosting provider. Not only is it cheaper in the long run but it is probably easier to use. You can do this by typing "npm run build" then uploading the files in the build folder to your hosts main directory either manually or by ftp in atom etc... but it's basically depends on your work flow and whether or not you have a dev ops guy on your team.

How does deploying a Node.js app using Strongloop on Heroku work?

Can someone with actual experience explain how these layers interact with each other and how a working setup (dev to production) should actually be, well, set up?
I understand there are buildpacks that serve to install Strongloop on Heroku. And that deploying the actual app is done with git push.
Some specific points that you could address...
How can I have (more or less) the same environment locally and at Heroku.
After setting up Strongloop Node, does the server environment stay in place? Or is it recreated every time I deploy an update? (if yes, how so?)
How does slnode fit into the picture
Can I connect to a db hosted at Heroku from a dev machine?
I hope answers to this question can serve as a guide for people like me who are struggling to understand how all the pieces go together.
I understand there are buildpacks that serve to install Strongloop on Heroku. And that deploying the actual app is done with git push.
You don't need our buildpack, and yes, you deploy with git push.
How can I have (more or less) the same environment locally and at Heroku.
How much more or less? You can develop on your mac laptop, and push to Heroku, using same version of node, or you can be more like Heroku, and use Linux, or ... what exactly about the Heroku env do you want to reproduce?
After setting up Strongloop Node, does the server environment stay in place? Or is it recreated every time I deploy an update? (if yes, how so?)
Not sure what setup you are referring to.
How does slnode fit into the picture
It doesn't.
Can I connect to a db hosted at Heroku from a dev machine?
Don't know, sorry, try Heroku support pages for this kind of heroku-specific tech question, perhaps?
I followed docs on bottom of page at http://docs.strongloop.com/display/DOC/Heroku, look for "Create Procfile and deploy", and it worked OK for me.
Fast answers
Use Vagrant, download a Debian 6 box, and install whatever you need in it, remember to check what version of Node.js Heroku uses.
It will be partially rebuilt, your npm dependencies will be redownloaded, your application gets rebuilt and so on.
You can use slnode on your dev machine. However if it is necessary to use slnode on a dyno, fork a build pack and install slnode as part of it.
You can connect to a database hosted on Heroku from any network connected server or pc, you will be provided with an ip and credentials.
Build packs
I'm not sure about actual constraints of a build pack, but it can do almost anything that you can do in an Debian 6 virtualized environment with shared kernel. ( An Debian 6 instance in a OpenVZ VPS )
Think of build packs as low level dependency managers which solve dependencies like node.js, Redis, Apache2 and so on.
They also build an environment like file system structure, ENV variables and so on.
Heroku infrastructure
Heroku is using AWS as it's raw hardware provider, AWS provides a fresh installation of an OS in a virtualized hardware ( VPS )
Heroku builds dynos on top of raw OS, by guess, it shares one OS between at least 128 dynos.
Each dyno is isolated from others, it has common software built in like ls, but it's build pack's duty to install any other software like Node.js for your application.
Heroku's node build pack, installs Node.js, and runs npm.

Resources