System Information
- Strapi Version: 4.7.0
- Operating System: Linux Ubuntu 20.04.5 LTS
- Database: postgresql
- Node Version: v16.19.0
- NPM Version: 8.19.3
- Yarn Version: 1.22.19
Today when I have started my application suddenly it threw me an error at /api/auth/local
endpoint. But when I made a request from thunderclient strapi always shows nothing but 401 unauthorized error without any response.
And also there is no log about the request.
The request in JS looks like this in my code:
// INITIATING USER TO GET JWT
const initiateUser = async (credentials) => {
const { identifier, password } = credentials;
const req = await fetch(host + "/api/auth/local", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ identifier, password }),
});
const response = await req.json();
if (response.jwt) {
setUser(response.user);
createCookiesToLocalStorage("jwt", response.jwt);
}
return response;
};
And kinda looks like this when using thunderclient:
let headersList = {
"Accept": "*/*",
"User-Agent": "Thunder Client (https://www.thunderclient.com)",
"Content-Type": "application/json"
}
let bodyContent = JSON.stringify({
"identifier": "masterbuilders1971@gmail.com",
"password": "*****************"
});
let response = await fetch("https://1337-abindent-onotebooknewup-m740rqznp2s.ws-us89.gitpod.io/api/auth/local", {
method: "POST",
body: bodyContent,
headers: headersList
});
let data = await response.text();
console.log(data);
But get requests are working fine…
Please help me…