Не работает http-proxy-middleware
Не работает прокси из npm-пакета "http-proxy-middleware".Настраивал следуя документации.
Вот код, который относится к прокси:
Код из файла сервера:
const { createProxyMiddleware } = require('http-proxy-middleware');
const auth = require('../routes/auth');
app.use('/auth', [
auth,
createProxyMiddleware({
target: `http://localhost:${PORT}`,
changeOrigin: true,
}),
]);
Код из файла API:
const axios = require('axios').default;
registration = async (data) => {
try {
const response = await axios.post('auth/registration', data);
return `Success: ${response.data.message}`;
} catch (error) {
console.log(error);
}
};
В терминале пишет:
[HPM] Proxy created: / -> http://localhost:5000
Server is working on port 5000...
А при нажатии на кнопку отправки данных в консоле браузера пишет:
POST http://localhost:3000/auth/registration 404 (Not Found)