servermiddleware routes are not recognized in production

My application communicates with several miscroservices, and I need to "hide" the API routes from the client, I'm trying the servermiddleware approach, on site it works, but when I go up to production it recognizes the route as being from the front and returns an html.

  • code snippet: server-middleware/proxy.js *
    ```js
    const express = require("express");
    const { createProxyMiddleware } = require("http-proxy-middleware");
const app = express();

app.use(
"/api/notifications",
createProxyMiddleware({
target: process.env.API_NOTIFICATIONS,
changeOrigin: true,
})
);
app.use(
"/api/customers",
createProxyMiddleware({
target: process.env.API_CUSTOMERS,
changeOrigin: true,
})
);

module.exports = app;
`

call in nuxt.config.js
js
serverMiddleware: ["~/server-middleware/proxy.js"],
````
Was this page helpful?