Strapi Error with Post request

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.

HTTP Headers

And also there is no log about the request.

The request in JS looks like this in my code:

  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) {
      createCookiesToLocalStorage("jwt", response.jwt);
    return response;

And kinda looks like this when using thunderclient:

let headersList = {
 "Accept": "*/*",
 "User-Agent": "Thunder Client (",
 "Content-Type": "application/json"

let bodyContent = JSON.stringify({
  "identifier": "",
  "password": "*****************"

let response = await fetch("", { 
  method: "POST",
  body: bodyContent,
  headers: headersList

let data = await response.text();

But get requests are working fine…

Please help me…

When sending auth don’t pass it as a data object

"identifier": "",
"password": "somerandompassword"

Maybe this can help ?

Do you know how to overcome with the CORS problem. I have already tried setting; mode to cors and setting headers like
'Access-Control-Allow-Headers': '[headers] ' but nothing is working…

I’ve actually got to know, that was a problem with gitpod. So that was fixed after restarting the codespace.

1 Like