mirror of
https://github.com/directus/directus.git
synced 2026-01-23 13:37:58 -05:00
Add root_redirect option (#4937)
* feat: don't expose admin url (optional) * Rename REDIRECT_TO_ADMIN -> ROOT_REDIRECT, add docs Co-authored-by: Michael Mullins <mullinsmikey@users.noreply.github.com>
This commit is contained in:
@@ -110,7 +110,14 @@ export default async function createApp() {
|
||||
html = html.replace(/href="\//g, `href="${publicUrl}`);
|
||||
html = html.replace(/src="\//g, `src="${publicUrl}`);
|
||||
|
||||
app.get('/', (req, res) => res.redirect(`./admin/`));
|
||||
app.get('/', (req, res, next) => {
|
||||
if (env.ROOT_REDIRECT) {
|
||||
res.redirect(env.ROOT_REDIRECT);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/admin', (req, res) => res.send(html));
|
||||
app.use('/admin', express.static(path.join(adminPath, '..')));
|
||||
app.use('/admin/*', (req, res) => {
|
||||
|
||||
@@ -35,6 +35,8 @@ const defaults: Record<string, any> = {
|
||||
REFRESH_TOKEN_COOKIE_SECURE: false,
|
||||
REFRESH_TOKEN_COOKIE_SAME_SITE: 'lax',
|
||||
|
||||
ROOT_REDIRECT: './admin',
|
||||
|
||||
CORS_ENABLED: true,
|
||||
CORS_ORIGIN: true,
|
||||
CORS_METHODS: 'GET,POST,PATCH,DELETE',
|
||||
|
||||
Reference in New Issue
Block a user