Skip to content

[Feature Request] Filter proxy request with method #349

@iMuFeng

Description

@iMuFeng

Sometimes I only want to proxy with the POST request cause the GET request don't need proxy.

'/login': {
        target: 'http://127.0.0.1:9090',
        changeOrigin: true
}

I need a /login page to render the login form, so I just want to proxy the POST /login request. May be we can add a method option:

'/login': {
        target: 'http://127.0.0.1:9090',
        changeOrigin: true,
        method: 'POST'
}

or we can handle the express next function of option.onProxyReq:

'/login': {
        target: 'http://127.0.0.1:9090',
        changeOrigin: true,
        onProxyReq: (proxyReq, req, res, next) => {
                if (req.method === 'GET') next()
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions