#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Deployment

Introduction to Deployment

Deployment is the process of taking an app that runs on your own computer and putting it on servers where real users can reach it through a URL. For a full stack JavaScript app, that usually means building the React frontend into static files, running the Node and Express backend on a hosting service, connecting a production database and setting configuration such as API keys through environment variables. Once authentication and auto logout work locally, deployment is the step that makes the app public.

Development build versus production build

During development, tools like Vite or Create React App run a dev server with hot reload, readable error messages and extra React checks. None of that should reach users. A production build bundles and minifies your code, removes development-only warnings and outputs plain HTML, CSS and JavaScript files in a folder such as dist or build. Those files can be served by any static host.

# Frontend (Vite)
npm run build        # creates dist/
npm run preview      # check the production build locally

# Backend
NODE_ENV=production node server.js

The pieces that need a home

PartWhat it is after buildingTypical hosting
React frontendStatic filesA static host or CDN, or served by Express
Express APIA long-running Node processA platform service, a container or a virtual server
DatabaseA managed service or a server you runA hosted MongoDB, PostgreSQL or MySQL instance
Secrets and configEnvironment variablesThe hosting dashboard or a secrets manager

You can deploy the frontend and backend separately, which scales them independently, or serve the built frontend from Express so everything sits on one domain. Both are valid.

Configuration changes between environments

Things that differ between your laptop and the server should never be hard-coded: the database connection string, the JWT secret, the API base URL the frontend calls, and allowed CORS origins. Read them from environment variables on the server, and from build-time variables such as import.meta.env.VITE_API_URL on the frontend. Remember that anything in a frontend build is visible to every visitor, so keep real secrets on the backend only.

Problems that appear only after deploying

The most common one is refreshing a page like /orders and getting a 404. Client-side routing works because React Router handles the URL in the browser, but on refresh the server looks for a real /orders file. The fix is a fallback rule that serves index.html for unknown paths, configured on the static host or in Express.

Other frequent surprises include API calls still pointing at localhost, CORS errors because the production frontend domain is not allowed by the backend, mixed-content errors when an HTTPS page calls an HTTP API, and the server crashing because it listens on a fixed port instead of process.env.PORT, which many platforms assign.

A basic pre-deployment checklist

  1. Run the production build locally and click through the main flows.
  2. Move every secret and URL into environment variables.
  3. Make the server listen on process.env.PORT.
  4. Add the SPA fallback so deep links work on refresh.
  5. Serve everything over HTTPS and set CORS to your real domain.
  6. Check server logs after the first deploy.

The idea to hold on to

Deploying is mostly about separating what changes per environment from what does not. Build the frontend, run the backend as a managed process, keep configuration in environment variables, and test the production build before users see it.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course