WEB SERVER with Node.js

Hey there! I'm Satya.
I love exploring different aspects of tech and life, and I enjoy sharing what I learn through stories and real-life examples. Whether it's web development, DevOps, networking, or even AI, I find joy in breaking down complex ideas into simple, relatable content.
If you're someone who loves learning and exploring these topics, I'd be really glad if you followed me on Hashnode. Let's learn and grow together! 😊
WEB SERVER
The term web server can refer to both side the hardware and the software , or both of them working together.
The hardware side = A web server is a computer that stores web software or website component files. A web server connects to the internet and support physical data interchange with other devices connected to the web.
The Software side = A web server includes several parts that control how web users access hosted files. At minimum this is an HTTP server. An HTTP server is a software that understands the URLs and HTTP.
An overview of HTTP
HTTP is a protocol for fetching resources such as HTML Documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser.
Clients and servers communicate by exchanging individual messages (as opposed to a stream of data). The messages sent by the client, usually a Web browser, are called requests and the messages sent by the server as an answer are called responses.
HTTP request methods
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs.
[GET](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET>)The
GETmethod requests a representation of the specified resource. Requests usingGETshould only retrieve data.[HEAD](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD>)The
HEADmethod asks for a response identical to aGETrequest, but without the response body.[POST](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST>)The
POSTmethod submits an entity to the specified resource, often causing a change in state or side effects on the server.[PUT](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT>)The
PUTmethod replaces all current representations of the target resource with the request payload.[DELETE](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE>)The
DELETEmethod deletes the specified resource.HTTP response status codes
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Informational responses (
100–199)Successful responses (
200–299)Redirection messages (
300–399)Client error responses (
400–499)Server error responses (
500–599)
Origin => Two URLs have the same origin if the protocol, port and host are same for both.
Same origin Policy => It is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a resource from another origin.
COR => Cross origin request = In browser terminology, the current browser URL is called the current origin and the third-party URL is cross-origin.
When you make a cross-origin request, this is the request-response process:
- The browser adds an origin header to the request with information about the current origin's protocol, host, and port.
CORS = Cross Origin Resource Sharing = CORS (Cross-Origin Resource Sharing) is a system, consisting of transmitting HTTP headers, that determines whether browsers block frontend JavaScript code from accessing responses for cross-origin requests.




