When i am using the api in the postman it is working fine, but when i am trying to call it using axio it is returning a webPage print loading.Preformatted text
axios code and output: useEffect(() => {
axios.get('/api/projects/search', {
headers: {
Authorization: 'Bearer squ_eae327a8a41ecdb560c91eb0da28d0d167c60e53'
}
}).then((response) => {
console.log(response.data);
});
}, [])
my proxy server code is:
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();
app.use(express.static('build', { fallthrough: true })); // Serve static files except for '/api'
// Proxy requests to SonarQube
app.use('/api', createProxyMiddleware({
target: 'http://localhost:9000',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}));
// Start the server
const port = process.env.PORT || 3001;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});

