Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion backend/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ const matchesPath = (pathname = '', target = '') => {
const configuredAdminHostname = getHostnameFromOrigin(getAdminOrigin());
const getRequestHostname = (req) => String(req.hostname || req.headers.host || '').split(':')[0].toLowerCase();

const adminStandalonePages = new Map([
['admin/storage', 'storage.html'],
['admin/calling', 'calling.html'],
['admin/calling-push', 'calling-push.html'],
['admin/social-auth', 'social-auth.html'],
]);

if (!config.isDev && config.serveFrontend) {
const publicRoot = path.resolve(__dirname, '..', '..', 'frontend', 'client', 'public');
const clientIndex = path.join(publicRoot, 'index.html');
const adminIndex = path.join(publicRoot, 'admin', 'index.html');
const adminRoot = path.join(publicRoot, 'admin');
const adminIndex = path.join(adminRoot, 'index.html');
const hasFrontendBuild = fs.existsSync(clientIndex) && fs.existsSync(adminIndex);
if (!hasFrontendBuild) {
console.warn('[startup] Frontend build files were not found. Client/admin routes will not be available.');
Expand All @@ -133,6 +141,16 @@ if (!config.isDev && config.serveFrontend) {
res.status(404).send('Not found');
return;
}

const standaloneAdminFile = adminStandalonePages.get(pathname);
if (standaloneAdminFile) {
const standalonePath = path.join(adminRoot, standaloneAdminFile);
if (fs.existsSync(standalonePath)) {
res.sendFile(standalonePath);
return;
}
}

if (isAdminHost || matchesPath(pathname, 'admin')) {
res.sendFile(adminIndex);
return;
Expand Down
7 changes: 7 additions & 0 deletions frontend/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ RewriteEngine On
# If Apache is serving this repository root, route public web requests
# to the generated frontend assets under client/public.

# Standalone admin pages are separate webpack entry points. Resolve their
# extensionless URLs before the generic admin SPA fallback.
RewriteRule ^admin/storage/?$ client/public/admin/storage.html [L]
RewriteRule ^admin/calling/?$ client/public/admin/calling.html [L]
RewriteRule ^admin/calling-push/?$ client/public/admin/calling-push.html [L]
RewriteRule ^admin/social-auth/?$ client/public/admin/social-auth.html [L]

# Admin subdomain SPA entry.
RewriteCond %{HTTP_HOST} ^admin\. [NC]
RewriteCond %{REQUEST_URI} !^/client/public/
Expand Down
Loading