fastify / fastify/fastify-http-proxy

Match by suffix (instead of prefix)

Open
#357 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
395
Forks
108
Avg merge
1d 19h
Merged PRs (30d)
2

Description

### Prerequisites

- [x] I have written a descriptive issue title
- [x] I have searched existing issues to ensure the feature has not already been requested

### 🚀 Feature Proposal

In porting an Express + `http-proxy-middleware` app, there's something I can't do; match by suffix rather than prefix.
My Express code looks like this:
```js
app.use("*/ping", backendProxy);
```
That means that any URL like `/foo/ping` or `/bla/ble/blu/ping` would be proxied away from this to that backend it was configured to.

This would be nice to be able to do with `fastify-http-proxy`.
(Perhaps it's possible with some hacks, but I can't figure it out)

### Motivation

Another use-case other than the one above is if you wanted to match by file extension. E.g.
```js
server.register(require('@fastify/http-proxy'), {
upstream: 'http://my-api.example.com',
pattern: '*.webp'
});
```

### Example

```js
server.register(require('@fastify/http-proxy'), {
upstream: 'http://my-api.example.com',
pattern: '*/info'
});
```
or
```js
server.register(require('@fastify/http-proxy'), {
upstream: 'http://my-api.example.com',
suffix: '/info'
});
```

it would match `http://localhost:3000/anything/info` or `http://localhost:3000/a/b/c/d/info`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.