Stateful :
• Server stores sessions
• Cookie-based
Stateless (JWT) :
• No server session
• Token sent every request
API Key :
• Authenticates apps, not users
OAuth 2.0 + OIDC :
• Powers "Login with Google/GitHub/Facebook"
#webdev#backend#jwt#oauth#api
Cookies - Small data stored in the browser.
Used for session IDs, preferences, or tokens.
Sessions - User data stays on the server.
Browser stores only the Session ID.
JWT - A signed token sent with each request.
Stateless & great for REST APIs.
#Authentication#Backend
Authentication
Answers: Who are you?
Examples:
• Password
• OTP
• Face ID
• Google Login
Authorization
Answers: What are you allowed to do?
Examples:
• Access dashboard
• Edit profile
• Delete users (Admin only)
#Authentication#Authorization#WebDevelopment#Backend
Response Codes :
- 2xx → Success
- 3xx → Redirect
- 4xx → Client Error
- 5xx → Server Error
Caching -Store responses so repeated requests are served faster.
Content Negotiation - The client tells the server what it prefers using headers:
#HTTP#RESTAPI#Backend
HTTP methods define the action a client wants to perform on a server.
GET → Read data
POST → Create data
PUT → Replace data
PATCH → Update part of data
DELETE → Remove data
HEAD → Headers only
OPTIONS → Supported methods
#WebDevelopment#RESTAPI#Backend#HTTP
HTTP Headers are Metadata sent with every HTTP Request & Response.
Types:
1. Request Headers→ Info sent by the client.
2. General Headers→ Apply to requests & responses.
3. Representation Headers→ Describe the content.
4. Security Headers→ Protect web apps from attacks.
HTTP Request vs HTTP Response :
Think of it like ordering food.
HTTP Request = You place an order.
Example:
GET /users/1
HTTP Response = The restaurant serves your food.
Example:
200 OK
{
"name": "Devendra"
}
#HTTP#WebDevelopment#Backend#Frontend#JavaScript
🌐 What is HTTP?
HyperText Transfer Protocol is how browsers and servers communicate.
Two key concepts:
1.Client–Server Model:
-Client sends requests
-Server processes & responds.
2.Stateless:
-Every HTTP request is independent.
-The server doesn't remember previous requests
Why can't we write backend logic in the frontend?
= Because the browser belongs to the user.
Anyone can:
View your JavaScript, Modify your code, Bypass validations , Access exposed secrets.
That's why the backend handles:
-Authentication
-Business logic
-API secrets
-Validation
Frontend is what users see. 👀
Backend is what makes everything work. ⚙️
Why do we need a backend?
-Store data
-Authenticate users
-Apply business logic
-Communicate with databases
-Provide APIs to the frontend
#NodeJS#Backend#MERN#ReactJS#WebDevelopment