Bridging the communication
As we mentioned, we will need to set up an HTTP proxy on the frontend side to solve the cross-origin request restriction. webpack-dev-server supports HTTP Proxy through the http-proxy-middleware library (https://github.com/chimurai/http-proxy-middleware). To bridge the requests, all we need to do is to change devServer.proxy in front-end/vue.config.js. Before we make the change, we need to come up with a proxy strategy. That is, the requests we will need to use the proxy and how to match those requests.
In general, there are two types of requests in a web application: the page requests and the API requests. The response of a page request is used for rendering a page, while the response of an API request is consumed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access