October 2019
Intermediate to advanced
426 pages
11h 49m
English
Finally, we have to define a proxy, to make sure that we can request our API from the same Uniform Resource Locator (URL) as the client. This is needed because, otherwise, we would have to deal with cross-site requests, which are a bit more complicated to handle. We are going to define a proxy that will forward requests from http://localhost:3000/api/ to http://localhost:4000/.
Now, let's configure the proxy:
> npm install --save http-proxy-middleware
const proxy = require('http-proxy-middleware')module.exports = function (app) { app.use(proxy('/api', {
Read now
Unlock full access