Posts

How to Prerender React Apps Using Prerender and NGINX

Image
The prerender service will cache the static HTML for a while before requesting a new copy from the server. This method did not require me to change anything on my React app and only required me to make some adjustments to the NGINX server configuration. This is how my application was being served before prerender came into the mix: After adding prerender, the flow looked something like this: Setting up prerender service There are two ways you can make use of the prerender service. You can either make use of the  paid hosted service  (contains a free plan as well) or you can run the  open source service  on your server and interface with that. I decided to opt for the latter. The first step was to install prerender on the server. It was fairly straightforward to do so using npm: $ npm install prerender The next step was to create a new node script that ran the service. These 3 lines are enough to get the service up and running: const prerender = require ( 'prerender' ); const

Lets Generate a free SSL certificate and run an HTTPS server in 5 minutes or less (Node + Express + LetsEncrypt)

Image
  What you actually came for First , you need those few things: A server running on a linux distribution with root access (via SSH) NodeJS:  https://nodejs.org/en/ Express :  npm install express Certbot To install certbot, copy-paste those lines in a terminal : $  sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install certbot Second , you will generate an SSL certificate with certbot : $ certbot certonly --manual Type your domain name(s) without the protocol part. For instance:  yourdomain.com  or even  muchdomain.verysite. Type  Y  then  ENTER. Note two things : a-string :  The name of the file you have to create, right now. Just create it, we’ll take care of the directories later. a-challenge:  Open the file you just created and put this challenge string into it. Nothing else, just this challenge string. Now, don’t continue. You need to run a web server with Node & Express. Keep your terminal opened somewhere Create a directory with the name you

How to Secure Session Management in Node

In a web application, data is transferred from a browser to a server over HTTP. In modern applications, we use the HTTPS protocol, which is HTTP over TLS/SSL (secure connection), to transfer data securely. Looking at common use cases, we often encounter situations where we need to retain user state and information. However, HTTP is a stateless protocol. Sessions are used to store user information between HTTP requests. We can use sessions to store users' settings like when not authenticated. Post authentication sessions are used to identify authenticated users. Sessions fulfill an important role between user authentication and authorization. Exploring Sessions Traditionally, sessions are identifiers sent from the server and stored on the client-side. On the next request, the client sends the session token to the server. Using the identifier, the server can associate a request with a user. Session identifiers can be stored in cookies, localStorage, and sessionStorage. Session identi

Popular posts from this blog

How to download a file using command prompt (cmd) Windows?

The future of Artificial Intelligence: 6 ways it will impact everyday life

How to Include ThreeJs in Your Projects