chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.68k stars 826 forks source link

pathFilter is not valid according to the TS files #839

Closed jcollum-nutrien closed 1 year ago

jcollum-nutrien commented 1 year ago

Checks

Describe the bug (be clear and concise)

In the docs:

createProxyMiddleware({ pathFilter: ['/api', '/ajax', '/someotherpath'], ...})

In my code:

app.use(
  '/hub-gql-proxy',
  createProxyMiddleware({
    target: 'https://redacted/',
    changeOrigin: true,
    pathFilter: ['/?GQLoperationName=redacted'],
  })
);

Result? TS error:

image

The TS binding doesn't have pathFilter in Options type.

export interface Options extends httpProxy.ServerOptions {
    pathRewrite?: {
        [regexp: string]: string;
    } | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
    router?: {
        [hostOrPath: string]: httpProxy.ServerOptions['target'];
    } | ((req: Request) => httpProxy.ServerOptions['target']) | ((req: Request) => Promise<httpProxy.ServerOptions['target']>);
    logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
    logProvider?: LogProviderCallback;
    onError?: OnErrorCallback;
    onProxyRes?: OnProxyResCallback;
    onProxyReq?: OnProxyReqCallback;
    onProxyReqWs?: OnProxyReqWsCallback;
    onOpen?: OnOpenCallback;
    onClose?: OnCloseCallback;
}

Outdated docs?

Step-by-step reproduction instructions

1. I think this is covered above
2. ...

Expected behavior (be clear and concise)

Docs or TS bindings are accurate.

How is http-proxy-middleware used in your project?

info This module exists because it's specified in "dependencies".
  "dependencies": {
    "@types/node": "17.0.12",
    "eslint": "8.24.0",
    "express": "4.18.2",
    "http-proxy-middleware": "2.0.6"
  },

What http-proxy-middleware configuration are you using?

see above

What OS/version and node/version are you seeing the problem?

package 2.0.6

`envinfo` won't run, appears to have a bug. It worked a few weeks ago.

Additional context (optional)

No response

chimurai commented 1 year ago

Looks like you are using v2.x. (v2 docs)

On github master you'll see documentation of the 3.0-beta version.

If you are looking at the github documentation you should see this:

image
jcollum-nutrien commented 1 year ago

Is the TS that's published to NPM out of sync with the code that's published to NPM?

If the 3.0 version works better I'll use that. I typically avoid beta software.

jcollum-nutrien commented 1 year ago

OK I get it, the docs aren't in sync with the published NPM version.

chimurai commented 1 year ago

Sorry for the confusion in the documentation on npm and github. Should clear up when v3 is finalised.