Custom context path in standard Strapi REST API endpoints

Team, is it possible to customise the Strapi REST API endpoints with some static context path before all the standard content type endpoints, something like “[server]/strapi/[content-type]/” ?

It is possible only when using proxy, like nginx.

You can also take a look at the documentation section:


module.exports = ({ env }) => ({
  host: env('HOST', ''),
  port:'PORT', 1337),
  url: '',

nginx config:

server {
    # Listen HTTP
    listen 80;

    # Redirect HTTP to HTTPS
    return 301 https://$host$request_uri;

server {
    # Listen HTTPS
    listen 443 ssl;

    # SSL config
    ssl_certificate /path/to/your/certificate/file;
    ssl_certificate_key /path/to/your/certificate/key;

    # Static Root
    location / {
        root /var/www/html;

    # Strapi API and Admin
    location /api/ {
        rewrite ^/api/(.*)$ /$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;

Thanks @sunnyson

Our setup is running Strapi as independent AWS cloud service accessed inside VPC without any proxy/gateway server in front of it. If that is the case, bringing in additional proxy server (like Nginx) for this specific use-case may not be possible in our setup.

Anyways will check if there are any other options to address this without proxy server.

sub-folder path prefixes are only possible with a proxy service like Nginx, HAProxy, Traefik, ect (Do not recommend Apache nor IIS as a proxy service, they support it but in a horrible and performance negative way).

The alternative, is give Strapi it’s own subdomain and isolate it from your frontend domain like instead of

1 Like

Thank you @DMehaffy.

In fact, we have subdomain defined like “[content-type]/…” Just thought of having “strapi” in the URL path as well for some internal processing if possible.

You can certainly do that, but you will need a proxy application as the koa-router will not apply the prefix internally. It’s only used in certain “public” urls

1 Like