mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Clean up App base url replacement (#9192)
This commit is contained in:
committed by
GitHub
parent
63ea5328ec
commit
2934b6ca76
@@ -132,16 +132,13 @@ export default async function createApp(): Promise<express.Application> {
|
||||
const adminUrl = new Url(env.PUBLIC_URL).addPath('admin');
|
||||
|
||||
// Set the App's base path according to the APIs public URL
|
||||
let html = fse.readFileSync(adminPath, 'utf-8');
|
||||
html = html.replace(
|
||||
/<meta charset="utf-8" \/>/,
|
||||
`<meta charset="utf-8" />\n\t\t<base href="${adminUrl.toString({ rootRelative: true })}/">`
|
||||
);
|
||||
const html = await fse.readFile(adminPath, 'utf8');
|
||||
const htmlWithBase = html.replace(/<base \/>/, `<base href="${adminUrl.toString({ rootRelative: true })}/" />`);
|
||||
|
||||
app.get('/admin', (req, res) => res.send(html));
|
||||
app.get('/admin', (req, res) => res.send(htmlWithBase));
|
||||
app.use('/admin', express.static(path.join(adminPath, '..')));
|
||||
app.use('/admin/*', (req, res) => {
|
||||
res.send(html);
|
||||
res.send(htmlWithBase);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user