Fix/admin path serve (#5287)

* Add config option to disable serving admin assets

Signed-off-by: Jozef Cipa <cipa.jozef@gmail.com>

* Add serveAdminPanel option to docs

Signed-off-by: Jozef Cipa <cipa.jozef@gmail.com>

* Inherit default value for serving admin from config

Signed-off-by: Jozef Cipa <cipa.jozef@gmail.com>
This commit is contained in:
Jozef Cipa 2020-03-12 09:39:25 +01:00 committed by GitHub
parent b2d19c8ad8
commit e8c4629779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -28,7 +28,7 @@ You might want to change the path to access to the administration panel. Here th
}
```
**You have to rebuild the administration panel to make this work.** [Build instructions](#build).
**You have to rebuild the administration panel to make this work.** [Build instructions](./customization.md#build).
## Deploy the administration panel on another server (AWS S3, Azure, etc) than the API.
@ -45,6 +45,7 @@ It's very common to deploy the front-end and the back-end on different servers.
},
"admin": {
"path": "/", // Note: The administration will be accessible from the root of the domain (ex: http//yourfrontend.com/)
"serveAdminPanel": false, // http://yourbackend.com will not serve any static admin files
"build": {
"backend": "http://yourbackend.com"
}

View File

@ -344,6 +344,16 @@ module.exports = function(strapi) {
'admin'
);
// check if we should serve admin panel
const shouldServeAdmin = _.get(
strapi.config.currentEnvironment.server,
'admin.serveAdminPanel',
strapi.config.serveAdminPanel
);
if (!shouldServeAdmin) {
strapi.config.serveAdminPanel = false;
}
strapi.config.admin.url = new URL(adminPath, strapi.config.url).toString();
};