Skip to content

Commit

Permalink
Merge pull request #19270 from strapi/v5/clean-root-url
Browse files Browse the repository at this point in the history
chore: remove default index page from public middleware
  • Loading branch information
alexandrebodin committed Jan 19, 2024
2 parents d99fe11 + 38a7e3c commit 1dd775d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 184 deletions.
37 changes: 37 additions & 0 deletions packages/core/core/src/middlewares/public.ts
@@ -0,0 +1,37 @@
import { defaultsDeep } from 'lodash/fp';
import koaStatic from 'koa-static';
import type { Strapi, Common } from '@strapi/types';

type Config = koaStatic.Options;

const defaults = {
maxAge: 60000,
};

export const publicStatic: Common.MiddlewareFactory = (
config: Config,
{ strapi }: { strapi: Strapi }
) => {
const { maxAge } = defaultsDeep(defaults, config);

strapi.server.routes([
{
method: 'GET',
path: '/',
handler(ctx) {
ctx.redirect('/admin');
},
config: { auth: false },
},
// All other public GET-routes except /uploads/(.*) which is handled in upload middleware
{
method: 'GET',
path: '/((?!uploads/).+)',
handler: koaStatic(strapi.dirs.static.public, {
maxage: maxAge,
defer: true,
}),
config: { auth: false },
},
]);
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
66 changes: 0 additions & 66 deletions packages/core/core/src/middlewares/public/index.html

This file was deleted.

94 changes: 0 additions & 94 deletions packages/core/core/src/middlewares/public/index.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/core/core/src/middlewares/public/serve-static.ts

This file was deleted.

0 comments on commit 1dd775d

Please sign in to comment.