I have a nestJS project and i want to proxy all API requests(using http-proxy-middleware) except the routes defined in the nestJS modules.
but nestJS seems to place app.use requests as priority.
How do I tell nestJS to take the AppModule routes as priority and call /api from the proxy only when the route is not present in the AppModule
e.g when I call /api/dosomething
it says not found
// AppModule contains routes such as `/api/dosomething
const app = await NestFactory.create(AppModule);
app.use('/api/*', proxy.createProxyMiddleware({
target: '/path/to/service', // contains /api/doanotherthing
changeOrigin: true,
secure: false,
})
);