i try to send a post request to my API but there is an error says
Refused to connect to ‘http://127.0.0.1:3000/api/v1/users/login’ because it violates the following Content Security Policy directive: “default-src ‘self'”. Note that ‘connect-src’ was not explicitly set, so ‘default-src’ is used as a fallback.
and this is the error from the API as i catch the err
message: “Network Error”
it is a simple post request by axios
import axios from 'axios';
export const login = async (email, password) => {
try {
const res = await axios({
method: 'POST',
url: 'http://127.0.0.1:3000/api/v1/users/login',
data: {
email,
password
}
});
console.log(res);
} catch (err) {
console.log(err);
}
};
i want put the endPoint of the API because it doesn't reach there.
here is all middlewars i used, maybe it cause the problem
app.use(express.static(path.join(__dirname, 'public'))); //to use static files like css in public folder
app.use(cookieParser());
app.use(helmet());
app.use(express.json());
app.use(mongoSanitize());
app.use(xss());
app.use(
hpp({
whitelist: [
'duration',
'ratingquantity',
'pricediscout',
'maxGroupSize',
'difficulty',
'price',
'ratingAverage',
],
}),
);
i try to eliminate the middlewars but it doesn’t work