Missing or broken API endpoint?

System Information
  • Strapi Version: 4.4.5
  • Operating System: Ubuntu 20.04
  • Database: Postgres
  • Node Version: 16.18
  • NPM Version: 8.19.2
  • Yarn Version:

Hi Strapi fellows!

I installed Strapi and since I’m already using /api adress, I manage to write these files to change it to “strapi”:

→ …config/server.js

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url: 'https://botike.com.br/strapi/',
  app: {
    keys: env.array('APP_KEYS'),
  },
});

→ /etc/nginx/sites-enabled/00-default-ssl.conf

    # Strapi API
    location /strapi/ {
        rewrite ^/strapi/(.*)$ /$1 break;
        proxy_pass http://strapi;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
    }
    # Strapi Dashboard
    location /strapi/admin/ {
        proxy_pass http://strapi/admin;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
    }

With this, I can expose the main page and the admin panel without no errors. But I couldn’t get no info from my-domain/strapi/endpoint:

{
	"data": null,
	"error": {
		"status": 404,
		"name": "NotFoundError",
		"message": "Not Found",
		"details": {}
	}
}

And I noted something: when I was trying to fix it generating a API Token, I noted that my choice of using “strapi” instead “api” didn’t get reflect on it:

I tryed to move back to “/api” and it didn’t worked either…

Any advice for this noob question will be highly appreciated :slight_smile:

I changed my /etc/nginx/sites-enabled/00-default-ssl.conf following this instructions, and using the “Subfolder unified” config.

→ part of /etc/nginx/sites-enabled/00-default-ssl.conf

    location /strapi/ {
        rewrite ^/strapi/?(.*)$ /$1 break;
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
    }

I realized that I was trying to reach my API endpoint using botike.com.br/strapi/botike-home and get the 404 error message. Now I’m using botike.com.br/strapi/api/botike-home and now the error is 403:

{
	"data": null,
	"error": {
		"status": 403,
		"name": "ForbiddenError",
		"message": "Forbidden",
		"details": {}
	}
}

I know that I’m making mistakes and asking silly questions, but I’m really lost on this matter…

Solution, after made an API Token and discover the populate parameter:

Strapi V4 populate Media and Dynamiczones from Components - Questions and Answers / Strapi Backend - Strapi Community Forum