Skip to content

Instantly share code, notes, and snippets.

@cloakedninjas
Last active December 15, 2021 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloakedninjas/43883563dd555f33d7940415a3a69395 to your computer and use it in GitHub Desktop.
Save cloakedninjas/43883563dd555f33d7940415a3a69395 to your computer and use it in GitHub Desktop.
Define top-level route in Strapi v4
// src/plugins/healthcheck/server/bootstrap.js
/**
With a plugin called healthcheck, this exposes a URL of /status without any /api or /admin prefix
**/
module.exports = ({ strapi }) => {
const routes = [
{
method: 'GET',
path: `/status`,
handler: 'healthcheck.index'
}
];
routes.forEach(route => {
route.info = { pluginName: 'healthcheck' };
route.config = {
auth: false
};
});
strapi.server.routes({
type: 'admin',
routes: routes
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment