ionic-team / ionic-team/ionic-cli

ability to rewrite location and cookies on v1-toolkit proxies

Đang mở
#4,770 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
triage
Ngôn ngữ chính
TypeScript
Star
2k
Fork
682
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Our app runs **ionic v1** and until now **we used Chrome** with some **security settings turned off** when testing our app in order to avoid most cross-origin issues like CORS and cookie samesite over HTTP when we call our REST API.

Recently **Chrome 94 dropped support of some flags** we really need like `SameSiteByDefaultCookies` or `CookiesWithoutSameSiteMustBeSecure`.

So **we decided to use ionic's *proxies* feature** which is configurable in `ionic.config.json`.

Unfortunately **we went through some impediments**:
1) one of **our api does some redirection** (like `http://testserver` 302-redirects to `http://testserver/otherapi`)
2) on production servers, **some cookies have a domain set**, which of course won't match the local test server entry point (usually http://localhost:8100)
3) we have a lot of different test servers, this would require a lot of entries in the proxies array.

To cover cases 1) and 2), we **implemented new settings** for the proxy (development has started on [a fork](https://github.com/esker-software/ionic-cli/tree/v1-toolkit-proxy-rewrite-location-and-cookie)):
* `cookieDomainRewrite: { [domain: string]: string };` **turns on rewriting cookie domain** on set-cookie headers
* `locationRewrite: boolean` **turns on rewriting location host+port AND path on redirection**. For example if you proxy `/api` to `http://testserver` then a header `Location: http://testserver/otherapi` would be rewritten to `Location: http://localhost:8100/api/otherapi`.
* `debug: boolean` **turns on verbose debugging** of `http-proxy-middleware`

I know v1 is quite old, but **could these features be of interest for other users** and so we might open a pull request ? Or maybe you have some suggestions ?

For case 3) we are willing to implement **dynamic proxy based on path**. The idea is to redirect on a different server based on a part of the path. Something that would be configurable this way:
```json
{
"path": "/api/*",
"proxyUrl": "http://$1/"
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.