Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove default index page from public middleware #19270

Merged
merged 1 commit into from Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.