π API Proxy
Configure the built-in dev server to forward specific paths to another server
To better emulate the actual production environment when developing web apps, you can specify paths that should be proxied to another server (e.g. your real API server or a local testing server) in a .proxyrc
, .proxyrc.json
or .proxyrc.js
file.
ΒΆ .proxyrc
/ .proxyrc.json
In this JSON file, you specify an object where every key is a pattern against which the URL is matched and the value is a http-proxy-middleware
options object:
This would cause http://localhost:1234/api/endpoint
to be proxied to http://localhost:8000/endpoint
.
ΒΆ .proxyrc.js
For more complex configurations, a .proxyrc.js
file allows you to attach any (connect-compatible) middleware, this example has the same behaviour as the .proxyrc
version above.
(This functionality is provided by @parcel/reporter-dev-server
.)