From dfb9c181f258afe71f5010153af82e3c2bcd946b Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:11:45 +0200 Subject: [PATCH] proxyrc.ts --- src/features/development.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/features/development.md b/src/features/development.md index 90d01064d..9b90af826 100644 --- a/src/features/development.md +++ b/src/features/development.md @@ -81,7 +81,7 @@ Parcel caches everything it builds to disk. If you restart the dev server, Parce By default, the cache is stored in the `.parcel-cache` folder inside your project. You should add this folder to your `.gitignore` (or equivalent) so that it is not committed in your repo. You can also override the location of the cache using the `--cache-dir` CLI option. -Caching can also be disabled using the `--no-cache` flag. Note that this only disables *reading* from the cache – a `.parcel-cache` folder will still be created. +Caching can also be disabled using the `--no-cache` flag. Note that this only disables _reading_ from the cache – a `.parcel-cache` folder will still be created. ## HTTPS @@ -101,7 +101,7 @@ parcel src/index.html --cert certificate.cert --key private.key ## API proxy -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. +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`, `.proxyrc.js` or `.proxyrc.ts` file. ### `.proxyrc` / `.proxyrc.json` @@ -127,9 +127,9 @@ In this JSON file, you specify an object where every key is a pattern against wh This example would cause `http://localhost:1234/api/endpoint` to be proxied to `http://localhost:8000/endpoint`. -### `.proxyrc.js` +### `.proxyrc.js`/`.proxyrc.ts` -For more complex configurations, a `.proxyrc.js` file allows you to attach any [connect](https://github.com/senchalabs/connect)-compatible middleware. First, make sure you install `http-proxy-middleware` into your project. This example has the same behaviour as the `.proxyrc` version above. +For more complex configurations, a `.proxyrc.js` or `.proxyrc.ts` file allows you to attach any [connect](https://github.com/senchalabs/connect)-compatible middleware. First, make sure you install `http-proxy-middleware` into your project. This example has the same behaviour as the `.proxyrc` version above. {% sample %} {% samplefile ".proxyrc.js" %} @@ -139,7 +139,8 @@ const { createProxyMiddleware } = require("http-proxy-middleware"); module.exports = function (app) { app.use( - createProxyMiddleware("/api", { + "/api", + createProxyMiddleware({ target: "http://localhost:8000/", pathRewrite: { "^/api": "",