Closed nightboyC closed 3 months ago
version 3.0.0-beta.1
Just type compatibility, req can obtain the corresponding key value
axios.get('/api/getApi')
app.use( '/api/:key', MiddlewareAPIProxy ); path :/ app.use( '/api', MiddlewareAPIProxy ); path: /getApi app.use( '/api/', MiddlewareAPIProxy ); path: /getApi Should it be unnecessary/
/api !== /api/ If it is not possible to modify the type, can I handle it so that I can switch from the first writing method to the third writing method
You can provide your own Request
and Response
type in v3.0.0
Here is an example with Next.js createProxyMiddleware<NextApiRequest, NextApiResponse>({ ... })
/** @type {import('http-proxy-middleware/dist/types').RequestHandler<express.Request, express.Response>} */
const exampleProxy = createProxyMiddleware({
target: 'http://www.example.org/api', // target host with the same base path
changeOrigin: true, // needed for virtual hosted sites
});
Describe the feature you'd love to see
_proxyReq, _req, _res _req Type incompatible with express req.params
Additional context (optional)
No response