mirror of
https://github.com/strapi/strapi.git
synced 2025-07-12 11:31:38 +00:00

* add possibility to use strapi on a non-root base url path * fix documentation password form * use server.url and admin.url in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update doc proxy Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * move server.url location in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * add possibility to put relative urls Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * allow '/' as an admin url + refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update yarn.lock Signed-off-by: Pierre Noël <petersg83@gmail.com> * refacto Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove default proxy option Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> * fix github provider Signed-off-by: Pierre Noël <petersg83@gmail.com> * fix github login Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove files that should be here Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> Co-authored-by: Pierre Noël <pierre.noel@strapi.io> Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com>
60 lines
1.6 KiB
JavaScript
Executable File
60 lines
1.6 KiB
JavaScript
Executable File
'use strict';
|
|
|
|
/**
|
|
* Module dependencies
|
|
*/
|
|
|
|
// Public node modules.
|
|
const _ = require('lodash');
|
|
const path = require('path');
|
|
const swaggerUi = require('swagger-ui-dist');
|
|
const koaStatic = require('koa-static');
|
|
|
|
// Variables.
|
|
const initialRoutes = [];
|
|
|
|
module.exports = strapi => {
|
|
return {
|
|
beforeInitialize() {
|
|
strapi.config.middleware.load.before.push('documentation');
|
|
|
|
initialRoutes.push(..._.cloneDeep(strapi.plugins.documentation.config.routes));
|
|
},
|
|
|
|
initialize() {
|
|
// Find the plugins routes.
|
|
strapi.plugins.documentation.config.routes = strapi.plugins.documentation.config.routes.map(
|
|
(route, index) => {
|
|
if (route.handler === 'Documentation.getInfos') {
|
|
return route;
|
|
}
|
|
|
|
if (route.handler === 'Documentation.index' || route.path === '/login') {
|
|
route.config.policies = initialRoutes[index].config.policies;
|
|
}
|
|
|
|
// Set prefix to empty to be able to customise it.
|
|
if (_.get(strapi.plugins, ['documentation', 'config', 'x-strapi-config', 'path'])) {
|
|
route.config.prefix = '';
|
|
route.path = `/${strapi.plugins.documentation.config['x-strapi-config'].path}${route.path}`.replace(
|
|
'//',
|
|
'/'
|
|
);
|
|
}
|
|
|
|
return route;
|
|
}
|
|
);
|
|
|
|
strapi.router.get('/plugins/documentation/*', async (ctx, next) => {
|
|
ctx.url = path.basename(ctx.url);
|
|
|
|
return await koaStatic(swaggerUi.getAbsoluteFSPath(), {
|
|
maxage: strapi.config.middleware.settings.public.maxAge,
|
|
defer: true,
|
|
})(ctx, next);
|
|
});
|
|
},
|
|
};
|
|
};
|