Home > Web Front-end > Front-end Q&A > What is node forwarding

What is node forwarding

WBOY
Release: 2022-04-22 15:10:29
Original
2277 people have browsed it

Node forwarding refers to the process in which when a user needs to request data, he or she can send a request to the front-end. After the front-end server receives the request, it sends a request to the back-end server to receive the data, and then forwards it to the user; request forwarding is the process of using node The request is forwarded to the backend, and the obtained data is returned to the frontend by the node. The node can be understood as a transfer station.

What is node forwarding

The operating environment of this tutorial: windows10 system, nodejs version 12.19.0, Dell G3 computer.

What is node forwarding

Definition

When the user needs to request data, the user sends a request to the front-end server, and then the front-end server receives it After the request, the request is sent to the back-end server to receive the data, and then forwarded to the user.

The essence of node forwarding is actually the same as that of webpack devServer, except that node forwarding is generally implemented by oneself, and webpack devServer is a definition Good configuration.

Node forwarding cross-domain understanding becomes the implementation of the webpack devServer principle

First of all, we need to understand what request forwarding is. Generally speaking, the front end requests data from the back end and needs the back end to There is a link on the front end. The front end directly requests the data on the connection. Request forwarding means using node to forward the request to the back end. The obtained data is returned to the front end by the node. It is understood that the node is like a transfer station.

Introducing the express module

express is a development framework based on node.js. You can use it to quickly build a fully functional website

When introducing express, create the package.json file first like introducing other modules, and then npm install it can be used

Use Node simulates back-end service

Suppose there are two services now: service A and service B. Here we use node to simulate a back-end service and put data on the service service {"data": "8091"}

What is node forwarding

At this point, switch to the parent folder of serverA.js in the terminal and enter the command node serverA.js. Service A is created.

Enter http://localhost:8091/ in the browser and you can see the data we put on service A {"data": "8091"}

Recommended learning:《nodejs video tutorial

The above is the detailed content of What is node forwarding. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template