Skip to main content

strapi-server

Strapi server​

In order to take full advantage of a proxied Strapi application, Strapi should be configured so it's aware of the upstream proxy. Like with the below configurations there are 3 matching examples. Additional information can be found in the server configuration and admin configuration documentations.

note

These examples use the default API Prefix of /api. This can be changed without the need to directly modify the Nginx configuration (see the API prefix documentation).

caution

If the url key is changed in the ./config/admin.js or ./config/server.js files, the admin panel needs to be rebuilt with yarn build or npm run build.

Subdomain" label="Subdomain">

Subdomain Strapi configuration​


  • Example domain: api.example.com
  • Example admin: api.example.com/admin
  • Example API: api.example.com/api
  • Example uploaded files (local provider): api.example.com/uploads
path: ./config/server.js

module.exports = ({ env }) ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://api.example.com',
});
path: ./config/server.ts

export default ({ env }) ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://api.example.com',
});

Subfolder unified" label="Subfolder unified">

Subfolder unified Strapi configuration​


  • Example domain: example.com/test
  • Example admin: example.com/test/admin
  • Example API: example.com/test/api
  • Example uploaded Files (local provider): example.com/test/uploads
path: ./config/server.js

module.exports = ({ env }) ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://example.com/test',
});
path: ./config/server.ts

export default ({ env }) ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://example.com/test',
});