What is the principle of cross-domain proxy proxyTable in node?

What is the principle of cross-domain proxy proxyTable in

1.node?

2. When I do not set CORS on both the browser and the server, I can cross-domain by setting proxytable. Does this go against the original intention of the same origin policy?

ps: would like to see a better explanation


Cross-domain is prohibited by browsers, and cross-domain is not prohibited by servers
. So browsers can send it to their own servers, and then forward them to servers that want to cross-domain. proxyTable of
vue-cli uses http-proxy-middleware middleware
create-react-app webpack-dev-server interior http-proxy-middleware
http-proxy-middleware http-proxy


you should say vue-cli In fact, when you run, will configure to start a node service, the role of this service is static file service 1, so that you can access html/js and other files, including monitoring file changes, 2 is to start a http proxy, your js request will be requested to this service A, from service A proxy to service B, while service An and static file server are of the same origin, and does not affect the same origin policy.
2. It is not necessary for the browser to set CORS . The server sets CORS to tell the browser to allow access to my source, which is not of the same origin with me, and to throw an error after the browser receives the response.

Menu